At 04:40 PM 9/25/2002, [EMAIL PROTECTED] wrote:

>Yeah, I have - it's a great example on how to write a custom validation
>method.  I'm trying to see if I can directly access additional form fields
>without having to specify each on as a <var>...</var> in my
>application-rules.xml.
>
>Jerry


Just added to validator, you can get access to the form from a validation 
rule by putting Validator in the method signature.  For example:


  public static boolean validateLastNameIsBob(Object bean,
       Field field,
       Validator validator) {
     Object form = validator.getResource(validator.BEAN_KEY);
     String lastName = ValidatorUtil.getValueAsString(form, "lastName);
     if (lastName.equals("Bob") return true;
     return false;
}

If you look in the unit tests for Validator, you can see a "requiredif" 
validation I wrote that does generic cross-field validations (i.e., last 
name is required if first name is filled in).  I'll be submitting as an 
enhancement for Struts Validator soon.

James


James




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

Reply via email to