struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Turner <tur...@blackbear.com>
Subject Weirdness/possible bug in Validator dependencies
Date Fri, 12 Jul 2002 22:18:03 GMT
Let's say I have two validations:
    <field
      property="gender"
      depends="required">
      <arg0 key="subscriberForm.gender.label"/>
     </field>
    <field
      property="dateOfBirth"
      depends="required,date">
      <arg0 key="subscriberForm.dateOfBirth.label"/>
     </field>

Now, on the form, I leave gender blank and put garbage in for dateOfBirth.

When the form validates, gender is given an error because it is blank, and 
dateOfBirth is not flagged at all.

Why?

Because in org.apache.commons.validator.Validator.validate(),  hActionsRun 
is defined outside of the main loop.  This
means that if any field fails the "required" test, dateOfBirth will never 
run the "date" check because the required
dependency fails, even though it's for another field.

If you then put an entry in gender, required passes, and on the next form 
submission, you finally get your error for dateOfBirth.

If hActionsRun were moved inside the loop, it would work 
correctly.  However, it would mean that one field couldn't have a 
dependency that was
defined by another, which I think is OK, since that's not supposed to be 
kosher as far as I can tell.  Should I submit that as a patch against commons?

James


--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message