Matthias

Thank you, that solved my issue without having to add the additional IF statement.  
Thank you for your quick response.

Cheers

Christopher

---- Original Message ----
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
From: "Matthias Wessendorf" <[EMAIL PROTECTED]>
Date: Thu, 20 May 2004 16:32:52 +0200
Subject: RE: ActionErrors and the example code

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]



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

Reply via email to