Highlighting the error line (even though only the first error is returned).  The input 
field in error's name will be returned with the error including the index I presume 
since no change was made to the 'hightlighting' code and it works.

sandeep

-----Original Message-----
From: Niall Pemberton [mailto:[EMAIL PROTECTED]
Sent: Friday, April 30, 2004 7:45 PM
To: Struts Users Mailing List
Subject: Re: Array Validation


To make this kind of feature useful there needs to be some way of indicating
which occurance of the "indexed" property is in error. So, for example,  if
you had a bunch of "order" beans and were validating the order value I would
want to be able to output a message along the lines of...

   "Order value for order number 12345 is invalid"
or
   "Order value on line 5 is invalid"

... where order number or line number are other properties from the bean
being validated. Otherwise if you had 20 errors on order value then you just
get 20 indetical messages along the lines of  "Order value is invalid" -
which isn't very useful.

I looked at trying to do this in the current validator but can't see how
to - have a missed something or am I right and its not possible?

This is an issue for me with the existing functionality where it stops on
the first indexed field in error - we got round it by outputing a message
which doesn't indicate which indexed occurance is in error, but by
highlighting the field in error, which works reasonably well.

That also would be another type of solution, validate all the indexed
properties, only show one generic message but highlight all the fields in
error.

I'd be happy if someone would either put me right on this, or say how they
dealt with this scenario.

Niall


----- Original Message ----- 
From: "Robert Leland" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, April 30, 2004 1:12 AM
Subject: Re: Array Validation


> > -----Original Message Slightly rearranged -----
> > From: Glenn, Scott [mailto:[EMAIL PROTECTED]
> >
> > If there are any Struts developers listening can you explain this .. is
it a
> > bug or by design?
>
> Doesn't matter. What matters is that it's not the behavior you need right
?
> If someone would like to develop and test a patch that adds an option to:
>   A) The <PlugIn > XML element in the struts-config.xml
>       This would change the default behavior to not stop validating on an
>       error for a given module.
> or
>   B) The Validator.xml itself, which would require a change to the
>      validator.dtd, either to:
>      B1) The form definition, so the behavior could be changed on a
>          per form basis.
>          The Option (whenInvalid ? ) would probably have four possible
>          values. [stop, inherit, all].
>             stop = This is the current default behavior
>             go   = This is the behavior you want, where it doesn't stop
>                        at the first error but attempts to validate all
data.
>             inherit = This would inherit the behavior from the parent
form.
>                       This assumes using Validator 1.2 which has a
>                       validator form inheritance.
>             module = Defers to what the modules default behavior is,
>                      assuming that option A) is also implemented.
> or
>      B2) The validator definition itself so it could be changed on a
>          per type basis.
>
>
> Of these A) Is the simplest and hence the fastest to develop and hence
test.
>             Because it?s the fastest it?s more likely to be in the
>             1.2.1 release because.
>
>
>   Long term Option B1) probably makes the most sense, but since it
>   requires a change to the commons Validator DTD, it won't make it into
>   Struts 1.2.1 since that will be using validator 1.1.3 which will be
>   released this weekend.
>
> The patch should include a unit test showing that the default behaviour
> in the same as in Struts 1.1, along with tests for each option.
>
>
>
> > Thanks,
> >
> > Scott.
> >
> >
> >
> >
> > FYI: Looks like this is a bug/feature of Struts validation.  If you have
a
> > List of indexed properties, it stops validating them once it has
discovered
> > the first error.
> >
> > The code below is from the Validator class - it loops around all indexed
> > fields (indexedList), calling the appropriate validate rule
> > (validateFieldForRule()).  However if this validate rule return false
into
> > the "good" variable, then the method exits without completing the loop.
> >
> > for (int pos = 0; pos < indexedList.length; pos++)
> > {
> >    ValidatorResults results = new ValidatorResults();
> >    StringTokenizer st = new StringTokenizer(field.getDepends(), ",");
> >    while (st.hasMoreTokens()) {
> >        String depend = st.nextToken().trim();
> >        ValidatorAction action = (ValidatorAction) actions.get(depend);
> >        if (action == null) {
> >            log.error("No ValidatorAction called "
> >                       + depend
> >                       + " found for field "
> >                       + field.getProperty());
> >            return;
> >       }
> >
> >       boolean good = validateFieldForRule(field, action, results,
actions,
> > pos);
> >       allResults.merge(results);
> >       if (!good)
> > {
> >          return;
> >       }
> >   }
> >
>
>
>
>
>
> ---------------------------------------------------------------------
> 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