I posted this message to the commons-user list but didn't receive any feedback. Basically, I am trying to get the indexedListProperty feature of Validator to allow me to report errors correctly for each property on a form that fails validation -- the only way I could get it to work was to change the Validator Field class -- I am trying to find out if there are any other known work arounds.
===================================
I have been working with indexedListProperty in Struts 1.2 (using Validator 1.1.3, I believe). Suppose I have the following validation:


----------------------------------------------------------------
<field property="partNumber" indexedListProperty="orders"
        depends="minlength">
   <arg position="0" key="prompt.partNumber"/>
   <arg position="1" key="${var:minlength}"
        resource="false"/>
   <var>
       <var-name>minlength</var-name>
       <var-value>5</var-value>
   </var>
</field>
----------------------------------------------------------------

Now, when I validate the form, if the minlength validation fails on one of the indexed properties, then none of the rest of the partNumber fields are checked for minlength.

I am using Struts and I was trying to output the error message beside the property using html:messages -- the result is that the error message is only generated for the first property that fails.

For what its worth, I did hack a fix -- I changed the

ValidatorResults validate(Map params, Map actions) method in the Field class [org.apache.commons.validator.Field].

Basically where it had (on line 724):
-----------------------------------------
                if (!good) {
                    return allResults;
                }
----------------------------------------

I made it ...
-----------------------------------------
                if (!good && numberOfFieldsToValidate <= 1) {
                    return allResults;
                }
----------------------------------------

This worked -- in other words I get all the messages generated for each field if the field is indexed.

Any opinions on ramifications of making this change or other possible solutions? I have not messed at all with the client-side javascript so I am not sure what the behavior is like there.

Bill Siggelkow


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



Reply via email to