I customised the validator just yesterday because it stops at the first error when using List-backed forms and indexedListProperty and I wanted it to run all validations down the page. I tried to extend the relevent class, but found too many methods were private or package access, rather than protected. So I just customised it and re-compiled.
I sent a mail to the dev-validator list, but got no replies. The hack is based on this email I found through google, except I just removed the offending lines of code completely! From: Bill Siggelkow <[EMAIL PROTECTED]> Subject: [Validator] Indexed properties Date: Thu, 12 Aug 2004 16:23:17 GMT Prev Next Prev by Thread Next by Thread -------------------------------------------------------------------------------- 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] On 14/10/05, Paul Benedict <[EMAIL PROTECTED]> wrote: > Does anyone ever run any custom versions of Struts or > the Commons library? The reason I ask is because the > bug that I need fix (it is now fixed) in Commons > Validator isn't released for the Struts 1.2.x branch, > but most likely will be released with Struts 1.3.... > Well I don't like using release 1 of anything :-) I > wouldn't want to upgrade to Struts 1.3 until it at > least gets into version 1.3.3 or something - the > theoretical risk for large bugs is high... Just think > of how many releases were for Struts 1.2! > > So what's the right solution here? I would like to see > a Strut 1.2.8, as I said, with an upgraded Commons > Validator too. Do I just compile a custom version of > Validator for myself? I'd like to hear opinions. > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > > --------------------------------------------------------------------- > 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]