Hi Bart, I'll try to look at this in the next couple of days. Could you file it as a bug report please so that it doesn't get forgotten:
http://jakarta.apache.org/commons/validator/issue-tracking.html If you have the time a patch (and test case) would be really great: http://www.apache.org/dev/contributors.html Thanks Niall On 2/16/06, bart vandendriessche <[EMAIL PROTECTED]> wrote: > Hi, > > I just started using Validator yesterday, and tried to find some info on > this particular problem but couldn't find anything, so my apologies if > this has been posted about before. > I'm using Validator outside of Struts, I don't believe this has any > impact on the situation, but I do find it strange that it was so hard to > find info on this, so I thought I'd mention it anyway. Right so, I > created a small form, made my own validation.xml and let the form post > to a servlet that would invoke Validator. So far so good. > > However, when I decided to implement a email field, and gave it 2 > dependencies, I was unable to access the results for both those > dependencies. Here's the code i used: > > ValidatorResults results = validator.validate(); > ValidatorResult result0 = > results.getValidatorResult("modelNumber"); > ValidatorResult result1 = > results.getValidatorResult("serialNumber"); > ValidatorResult result2 = > results.getValidatorResult("firstName"); > ValidatorResult result3 = > results.getValidatorResult("lastName"); > ValidatorResult result4 = results.getValidatorResult("email"); > > log.debug("Modelnumber: " + result0.isValid("required")); > log.debug("Serialnumber: " + result1.isValid("required")); > log.debug("First name: " + result2.isValid("required")); > log.debug("Last name: " + result3.isValid("required")); > > for( Iterator it = > result4.getActionMap().keySet().iterator();it.hasNext();) { > log.debug("key in result for email: " + it.next().toString()); > } > log.debug("result4.containsAction(required)" + > result4.containsAction("required")); > log.debug("Email: " + result4.isValid("required")); > log.debug("Email: " + result4.isValid("isEmail")); > > > Now, the output of the for loop, would only list the last dependency run > on the email field. I took a dive into the code and after some > searching, I edited the org.apache.commons.validator.Field class as follows: > > move the line: > > 844: ValidatorResults results = new ValidatorResults(); > > to > > 835: ValidatorResults results = new ValidatorResults(); > > > By moving it outside the dependencies loop, I was able to retrieve > results for all the dependencies associated with a field. > > Hope this helps anyone, > Bart > > --------------------------------------------------------------------- > 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]
