struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Raeburn" <sraeb...@apache.org>
Subject RE: Can Validator javascript show more than one error at a time?
Date Sun, 27 Jul 2003 21:30:56 GMT
To correct myself:
  "Due to the way the && expression is evaluated, if any tests returns
*false* the subsequent tests are not executed."

This is because the && operator uses short-circuit evaluation. If any of the
tests return false then the whole expression must be false, so the
subsequent tests are not evaluated.

The & operator does not use short-circuit evaluation so all tests are
evaluated.

This only affects the Javascript validation tests - the server validations
are always all run.

Steve

> -----Original Message-----
> From: Brian Alexander Lee [mailto:brian_a_lee@hotmail.com]
> Sent: July 27, 2003 6:34 AM
> To: Struts Users Mailing List; sraeburn@apache.org
> Subject: Re: Can Validator javascript show more than one error at a
> time?
>
>
> There's currently a defect
> (http://issues.apache.org/bugzilla/show_bug.cgi?id=20754)
> in bugzilla that would use "&" (bitwise operator) instead of "&&" so it
> would process all validations.
>
> You can apply the patch yourself. It's only two files ValidatorPlugIn.java
> and JavascriptValidatorTag.java.
>
> BAL
> ----- Original Message -----
> From: "Steve Raeburn" <sraeburn@apache.org>
> To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> Sent: Saturday, July 26, 2003 2:33 PM
> Subject: RE: Can Validator javascript show more than one error at a time?
>
>
> > The generated Javascript groups tests by type (required, mask,
> min length
> > etc) and calls them as follows:
> >
> >   function validateRegistrationForm(form) {
> >    if (bCancel)
> >       return true;
> >     else
> >       return validateRequired(form) &&
> >              validateMask(form) &&
> >              validateMinLength(form) &&
> >              validateMaxLength(form) &&
> >              validateEmail(form);
> >   }
> >
> > Due to the way the && expression is evaluated, if any test returns true
> the
> > subsequent tests are not executed.
> >
> > If you had several missing required fields then those errors would be
> > grouped together. But if you had only one missing required field and
> another
> > type of error, you would not see the second error message until you
> correct
> > the missing field error.
> >
> > See the struts-validator sample application (shipped with Struts) for
> > examples.
> >
> > Steve
> >
> > > -----Original Message-----
> > > From: news [mailto:news@main.gmane.org]On Behalf Of Brian Chaplin
> > > Sent: July 26, 2003 10:35 AM
> > > To: struts-user@jakarta.apache.org
> > > Subject: Can Validator javascript show more than one error at a time?
> > >
> > >
> > > Somehow Ted Husted was able to get the javascript to show
> more than one
> > > error at a time in the javascript alert message.
> > > See screen shot on page 373 of Struts in Action.
> > > I'm using Struts 1.1 final and it seems the javascript won't support
> that?
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message