Hi,

I wrote a validation to compare two fields of the same form (I used the validateTwoFields example in the struts validation user's guide).  My problem is the the form is displayed over multiple pages.  I do store the form in the session so all properties of the form should be available.  When I call my validate method, I get a the following error:

ValidatorUtil - -Unknown property 'phaseSelected' <java.lang.NoSuchMethodException: Unknown peroperty 'phaseSelected'.

Now, I played with it a little bit.  It seems as though when I validate two fields on the same page my validate works.  Does anyone have an example of validating two fields from different pages or does anyone see what I am missing.  The rest of my code is below:

from the validation.xml file:

<field property="defectOriginSelected" indexedListProperty="defectsList" depends="validwhen,compareTwoFields" page="4">
          <arg0 key="label.revRec.defectOrigin"/>
          <arg1 key="label.revRec.phase"/>
          <var>
             <var-name>test</var-name>
             <var-value>
                ((defectsList[].actionItemIndicator!="false") or (*this* != "0"))
             </var-value>
          </var>
          <var>
             <var-name>secondProperty</var-name>
             <var-value>phaseSelected</var-value>
          </var>
 
       </field>

Here is my validateTwoFields method:

   public static boolean validateTwoFields(Object bean,
                                           ValidatorAction va,
                                           Field field,
                                           ActionErrors errors,
                                           Validator validator,
                                           HttpServletRequest request) {

      System.out.println("in validateTwoFields");
      String value = ValidatorUtil.getValueAsString(bean, field.getProperty());
      String sProperty2 = field.getVarValue("secondProperty");
      String value2 = ValidatorUtil.getValueAsString(bean, sProperty2);

      if (!GenericValidator.isBlankOrNull(value)) {
         try {
            //get int representation of values to compare
            int val1 = Integer.parseInt(value);
            int val2 = Integer.parseInt(value2);
            if (val1 < val2) {
                errors.add(field.getKey(), Resources.getActionError(request,va,field));
                return false;
             } else {
               return true;
             }
         } catch (Exception e) {
            errors.add(field.getKey(),Resources.getActionError(request,va,field));
            return false;
         } finally {
         }
      } else {
         return true;
      }
   }
 

The phaseSelected property is on page 1 and it is not an indexed property.

Can anyone help??

Thanks,

Natalie

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

Reply via email to