Re: Use the Source, Luke!

2007-12-12 Thread Antonio Petrelli
2007/12/11, Frank W. Zammetti <[EMAIL PROTECTED]>:
>
> Hi Antonio... I see the ticket hasn't been updated, and at least as of
> last night, with latest updates, the failure is still present.  do you
> have any idea when you might get to this?  Just so I know whether I should
>
> hack the code somehow to get the build to succeed, at least enough for me
> to work on what I wanted to, or just wait for the real fix.



Do you mean that, with of my latest commit r603355, you have problems?
In this case, I have to test it with a real JDK 1.4 (I can do it this
evening CET).

Ciao
Antonio


RE: In regards to Struts 2 Validation.

2007-12-12 Thread Bob Tiernay

Fair enough. But HV still doesn't have a full set of validation features in my 
opinion.
 
Perhaps we should discuss what is wrong with our current validation support, 
and what we want to accomplish.  I believe all we need are some simple changes 
to take us most of the way there.  My personal thoughts have been captured here 
(just replace the word "OVal" with "Struts2 Validation"): 
 
http://sourceforge.net/forum/forum.php?thread_id=1889936&forum_id=488109
 
> Date: Tue, 11 Dec 2007 03:38:50 -0800> From: [EMAIL PROTECTED]> To: 
> dev@struts.apache.org> Subject: Re: In regards to Struts 2 Validation.> > 
> Hmmm, I'd say that it's still a safe bet that Hibernate Validator will> have 
> a "profound effect" on JSR 303, akin to JPA and Hibernate Core.> I've seen 
> posts on the Hibernate list that imply JSR 303 will be> backwardly compatible 
> with HV.> > -Ted.> > On Dec 10, 2007 4:37 PM, Bob Tiernay <[EMAIL PROTECTED]> 
> wrote:> >> > I believe that OVal will soon be a referenced as existing 
> technology for this JSR:> >> > 
> http://sourceforge.net/forum/forum.php?thread_id=1640398&forum_id=488109> >> 
> > -> To 
> unsubscribe, e-mail: [EMAIL PROTECTED]> For additional commands, e-mail: 
> [EMAIL PROTECTED]> 
_
Exercise your brain! Try Flexicon!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig

Re: In regards to Struts 2 Validation.

2007-12-12 Thread Ted Husted
A good place to start might be with a set of use cases that
demonstrate various validation scenarios. We could then try to
implement the use cases using the XW validation, Commons validator,
and Hibernate Validator, and compare the outcome.

-- HTH, Ted
 * 

On Dec 12, 2007 5:18 AM, Bob Tiernay <[EMAIL PROTECTED]> wrote:
>
> Fair enough. But HV still doesn't have a full set of validation features in 
> my opinion.
>
> Perhaps we should discuss what is wrong with our current validation support, 
> and what we want to accomplish.  I believe all we need are some simple 
> changes to take us most of the way there.  My personal thoughts have been 
> captured here (just replace the word "OVal" with "Struts2 Validation"):
>
> http://sourceforge.net/forum/forum.php?thread_id=1889936&forum_id=488109
>
> > Date: Tue, 11 Dec 2007 03:38:50 -0800> From: [EMAIL PROTECTED]> To: 
> > dev@struts.apache.org> Subject: Re: In regards to Struts 2 Validation.> > 
> > Hmmm, I'd say that it's still a safe bet that Hibernate Validator will> 
> > have a "profound effect" on JSR 303, akin to JPA and Hibernate Core.> I've 
> > seen posts on the Hibernate list that imply JSR 303 will be> backwardly 
> > compatible with HV.> > -Ted.> > On Dec 10, 2007 4:37 PM, Bob Tiernay 
> > <[EMAIL PROTECTED]> wrote:> >> > I believe that OVal will soon be a 
> > referenced as existing technology for this JSR:> >> > 
> > http://sourceforge.net/forum/forum.php?thread_id=1640398&forum_id=488109> 
> > >> > -> 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]> For additional commands, e-mail: 
> > [EMAIL PROTECTED]>
> _
> Exercise your brain! Try Flexicon!
> http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Use the Source, Luke!

2007-12-12 Thread Frank W. Zammetti
It's possible I didn't get that one... I'll try tonight when I get home
and let you know.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Wed, December 12, 2007 3:06 am, Antonio Petrelli wrote:
> 2007/12/11, Frank W. Zammetti <[EMAIL PROTECTED]>:
>>
>> Hi Antonio... I see the ticket hasn't been updated, and at least as of
>> last night, with latest updates, the failure is still present.  do you
>> have any idea when you might get to this?  Just so I know whether I
>> should
>>
>> hack the code somehow to get the build to succeed, at least enough for
>> me
>> to work on what I wanted to, or just wait for the real fix.
>
>
>
> Do you mean that, with of my latest commit r603355, you have problems?
> In this case, I have to test it with a real JDK 1.4 (I can do it this
> evening CET).
>
> Ciao
> Antonio
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: In regards to Struts 2 Validation.

2007-12-12 Thread Tom Schneider
I have plenty of examples from our application.

The first is a case where the user must enter at least one phone
number and if the type of phone is selected, then the user must enter
a phone number.  The validation code is as follows:

if(!hasFieldErrors("exampleData.phoneNumber1") &&
   !hasFieldErrors("exampleData.phoneNumber2") &&
   !hasFieldErrors("exampleData.phoneNumber3") &&
   !hasFieldErrors("exampleData.phoneNumber4"))
{
  if((!exampleData.getPhoneNumber1().equals("")&&
exampleData.getPhoneType1()== 0) ||
 (!exampleData.getPhoneNumber2().equals("")&&
exampleData.getPhoneType2()== 0) ||
 (!exampleData.getPhoneNumber3().equals("")&&
exampleData.getPhoneType3()== 0) ||
 (!exampleData.getPhoneNumber4().equals("")&&
exampleData.getPhoneType4()== 0))
  {
addActionError(getText("phoneType.error"));
  }

  if((exampleData.getPhoneNumber1().equals("")&&
exampleData.getPhoneType1()!= 0) ||
 (exampleData.getPhoneNumber2().equals("")&&
exampleData.getPhoneType2()!= 0) ||
 (exampleData.getPhoneNumber3().equals("")&&
exampleData.getPhoneType3()!= 0) ||
 (exampleData.getPhoneNumber4().equals("")&&
exampleData.getPhoneType4()!= 0))
  {
addActionError(getText("phoneNumber.error"));
  }
}

Note, I did not write this, this is taken straight from our source code.

The second example I have is a case where we want to use some logic to
validate prescription information.  The validation for prescriptions
is tricky because the user doesn't have to enter prescriptions, but if
anything is entered for a prescription, then the prescription data is
fully validated.  Note that we have several places in the app where
this is done so I'd prefer not to duplicate this validation logic in
all the places we need it.  (i.e. don't want to violate the DRY
principle)  I broke this out into a helper class for reusability.  The
isEmpty() method on PrescriptionData checks to see if there is any
data populated.

  public void validate(String propertyPrefix, List prescriptionList,
ValidationAware errors, TextProvider textProvider)
  {
for (int i = 0; i < prescriptionList.size(); i++)
{
  PrescriptionData data = (PrescriptionData) prescriptionList.get(i);
  // pull out conversion errors and set original values
  ActionInvocation invocation =
ActionContext.getContext().getActionInvocation();
  Map conversionErrors =
invocation.getInvocationContext().getConversionErrors();
  if (!data.isEmpty())
  {
if (data.getApplicantId() == 0)
{
  errors.addFieldError("medication", textProvider
.getText("medicalQuestions.applicant.required"));
}
if (ValidationUtils.isStringEmpty(data.getMedication()))
{
  errors.addFieldError("medication", textProvider
.getText("medicalQuestions.medication.required"));
}
if (ValidationUtils.isStringEmpty(data.getDescription()))
{
  errors.addFieldError("description", textProvider
.getText("medicalQuestions.dosage.required"));
}

if (!hasConversionError(propertyPrefix + "[" + i +
"].startDate", conversionErrors) && data.getStartDate() == null)
{
  errors.addFieldError("startDate", textProvider
.getText("medicalQuestions.startDate.required"));
}
if (data.getStartDate() != null && data.getEndDate() != null)
{
  Calendar startCal = Calendar.getInstance();
  startCal.setTime(data.getStartDate());
  Calendar endCal = Calendar.getInstance();
  endCal.setTime(data.getEndDate());
  if (startCal.after(endCal))
  {

errors.addActionError(textProvider.getText("medicalQuestions.startAfterEnd"));
  }
}
  }
}
  }

The final example is a case where some might consider it a 'business
rule', however, in my opinion, validation is validation regardless of
whether you're implementing business rule validation or simple UI
validation.  My argument for this is the fact that the simple UI
validation is used as part of the business rule validation.  (For
example, you might need to check that a string is not blank or null)
In this use case, we allow the user to enter a state and a zip and we
verify that the state and zip match.  We do this by making sure that
the combination of state and zip produce at least one valid county.

if (!hasFieldErrors("siteLocationView.zip")
  && !hasFieldErrors("siteLocationView.state"))
{
  CountyData counties[] =
siteLocationProcess.getCountiesForZipAndState(siteLocationView
.getZip(), siteLocationView.getStateAbbr());
  if (counties.length < 1)
  {
addActionError(getText("siteLocationView.zipcountymismatch.error"));
  }
}

This is a case where the validation is dependent on a business process object.

There's plenty more where that came from, so if you nee

Re: Use the Source, Luke!

2007-12-12 Thread Paul Benedict
What's that famous developer line? "Well it works for me" :D


On Dec 12, 2007 9:11 AM, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:

> It's possible I didn't get that one... I'll try tonight when I get home
> and let you know.
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM/Yahoo: fzammetti
> MSN: [EMAIL PROTECTED]
> Author of "Practical Ajax Projects With Java Technology"
>  (2006, Apress, ISBN 1-59059-695-1)
> and "JavaScript, DOM Scripting and Ajax Projects"
>  (2007, Apress, ISBN 1-59059-816-4)
> Java Web Parts - http://javawebparts.sourceforge.net
>  Supplying the wheel, so you don't have to reinvent it!
>
> On Wed, December 12, 2007 3:06 am, Antonio Petrelli wrote:
> > 2007/12/11, Frank W. Zammetti <[EMAIL PROTECTED]>:
> >>
> >> Hi Antonio... I see the ticket hasn't been updated, and at least as of
> >> last night, with latest updates, the failure is still present.  do you
> >> have any idea when you might get to this?  Just so I know whether I
> >> should
> >>
> >> hack the code somehow to get the build to succeed, at least enough for
> >> me
> >> to work on what I wanted to, or just wait for the real fix.
> >
> >
> >
> > Do you mean that, with of my latest commit r603355, you have problems?
> > In this case, I have to test it with a real JDK 1.4 (I can do it this
> > evening CET).
> >
> > Ciao
> > Antonio
> >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Use the Source, Luke!

2007-12-12 Thread Antonio Petrelli
2007/12/12, Frank W. Zammetti <[EMAIL PROTECTED]>:
> It's possible I didn't get that one... I'll try tonight when I get home
> and let you know.

I tested compiling using j2sdk 1.4.2_16 (Kubuntu 7.10) and it worked.

Ciao
Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Use the Source, Luke!

2007-12-12 Thread Frank W. Zammetti
Good news: I was in fact missing some updates, and sure enough it's 
working now.  Thanks guys, I can get to work now :)


Frank

Antonio Petrelli wrote:

2007/12/12, Frank W. Zammetti <[EMAIL PROTECTED]>:

It's possible I didn't get that one... I'll try tonight when I get home
and let you know.


I tested compiling using j2sdk 1.4.2_16 (Kubuntu 7.10) and it worked.

Ciao
Antonio

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Use the Source, Luke!

2007-12-12 Thread Dave Newton
Complete with certification logo:

http://img88.imageshack.us/img88/8713/worksonmymachinebiglh2.png

d.

--- Paul Benedict <[EMAIL PROTECTED]> wrote:

> What's that famous developer line? "Well it works for me" :D
> 
> 
> On Dec 12, 2007 9:11 AM, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:
> 
> > It's possible I didn't get that one... I'll try tonight when I get home
> > and let you know.
> >
> > --
> > Frank W. Zammetti
> > Founder and Chief Software Architect
> > Omnytex Technologies
> > http://www.omnytex.com
> > AIM/Yahoo: fzammetti
> > MSN: [EMAIL PROTECTED]
> > Author of "Practical Ajax Projects With Java Technology"
> >  (2006, Apress, ISBN 1-59059-695-1)
> > and "JavaScript, DOM Scripting and Ajax Projects"
> >  (2007, Apress, ISBN 1-59059-816-4)
> > Java Web Parts - http://javawebparts.sourceforge.net
> >  Supplying the wheel, so you don't have to reinvent it!
> >
> > On Wed, December 12, 2007 3:06 am, Antonio Petrelli wrote:
> > > 2007/12/11, Frank W. Zammetti <[EMAIL PROTECTED]>:
> > >>
> > >> Hi Antonio... I see the ticket hasn't been updated, and at least as of
> > >> last night, with latest updates, the failure is still present.  do you
> > >> have any idea when you might get to this?  Just so I know whether I
> > >> should
> > >>
> > >> hack the code somehow to get the build to succeed, at least enough for
> > >> me
> > >> to work on what I wanted to, or just wait for the real fix.
> > >
> > >
> > >
> > > Do you mean that, with of my latest commit r603355, you have problems?
> > > In this case, I have to test it with a real JDK 1.4 (I can do it this
> > > evening CET).
> > >
> > > Ciao
> > > Antonio
> > >
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Result types for S1

2007-12-12 Thread Frank W. Zammetti
So, now that I've gotten my build problems sorted out, I was able to 
make some quick progress on what I wanted to work on, enough that I want 
to run this by everyone before I spit, polish and submit patches.


Ted and I were discussing some ideas at The Ajax Experience back in 
October, specifically on how we could make S1 a little more 
AJAX-friendly and useful to developers doing RIA development.  One of 
the ideas I had was the ability to have, essentially, "result types" in 
S1, ala S2.


As a concrete example, say I have an Action that does this at the end:

return mapping.findForward("JSONResultType");

That mapping name would be a value specially recognized by Struts.  The 
result of doing that would be that the response is a JSON representation 
of the appropriate ActionForm.  One can easily imagine an XMLResultType, 
a FreemarkerResultType, a DataVisionResultType, and so on.


Note that the developer *does not* need to add any configuration to 
struts-config, they have only to specify that forward name, and the 
ActionForm to JSON conversion is automatic.


I have this JSONResultType working right now, and it turns out it's a 
minimally intrusive change to the S1 code base overall, consisting of:


* Some frankly minor changes to two Chain Commands

* The addition of a new package containing one new class (the class that 
actually generates the result output, more to follow as new result types 
are implemented)


* Some new dependencies: one during build (json-lib), and four at 
runtime (if using that result type): Commons Collections, Commons Lang, 
JSON-Lib and EZMorph).


To be clear, this code isn't complete and ready immediately, it's POC 
grade right now, but it's not too far off either, maybe an hour or two 
worth of polishing.


So, does anyone else think this is a worthwhile exercise?  I certainly 
think it is: the ability to have automatic conversion of an ActionForm 
to JSON, XML, or whatever else, means S1 can become a true service 
provider for AJAX-based clients with no real effort on the developers' 
parts.  It's not a huge change to the Struts code base, doesn't break 
compatibility in any way (I suppose unless someone happens to have the 
exact forward names I'm proposing here in their app already), and aside 
from the added dependencies, I don't see a down-side.


Thoughts?

Frank

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]