hi christopher,

if i understand you right, you watch RegistrationForm.java

note, that this class extends ValidatorForm
and not ActionForm.

ActionForm.validate() returns NULL

ValiForn.validate() returns an ActionErros-Objekt
(see CVS-code):
http://cvs.apache.org/viewcvs.cgi/jakarta-struts/src/share/org/apache/st
ruts/validator/ValidatorForm.java?view=markup


cheers,
Matze

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 20, 2004 11:05 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: ActionErrors and the example code
> 
> 
> I have developed my way around this issue, but I wanted to 
> pass it by you to see if my logic is not flawed.
> 
> In the example given with the Struts packages, it performs 
> validation within a form like so:
> 
> public ActionErrors validate(ActionMapping mapping, 
> HttpServletRequest request) 
> {
>    // Perform validator framework validations
>    ActionErrors errors = super.validate(mapping, request);
> 
>    // Only need crossfield validations here
>    if (!password.equals(password2)) 
>    {
>       errors.add("password2",
>                        new ActionError("error.password.match"));
>    }
>    return errors;
> }
> 
> I believe that an error will be raised at the line beginning 
> errors.add(.  The reason is the super.validate will return a 
> null if no errors are created within it, and you can’t 
> perform an ‘add’ on a null object.  Therefore, the code 
> should look like this:
> 
> public ActionErrors validate(ActionMapping mapping, 
> HttpServletRequest request) 
> {
>    // Perform validator framework validations
>    ActionErrors errors = super.validate(mapping, request);
> 
>    // Only need crossfield validations here
>    if (!password.equals(password2)) 
>    {
>       if (errors == null)
>           errors = new ActionError();
> 
>       errors.add("password2",
>                        new ActionError("error.password.match"));
>    }
>    return errors;
> }
> 
> Am I correct in my logic?  I have tested this and I find it 
> to be true.
> 
> Christopher
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to