StrutsValidWhen

HomePage | RecentChanges | Preferences

Notes on validwhen

Some working examples...

<!-- Either a residence or a business address is required -->
<field property="addressLines" depends="validwhen">
   <arg key="label.either.address"/>
   <var>
      <var-name>test</var-name>
      <var-value>
         (
            ( ( ( (*this* != null) and (city != null) ) and (state != null) ) and (zip != null) )
            or
            ( ( ( (businessAddressLines != null) and (businessCity != null) ) and (businessState  != null) ) and (businessZip != null) )
         )
      </var-value>
   </var>
</field>


Assertion: There is no client-side validation available for validwhen

True. The bundled validator-rules.xml file has no 'jsFunction' attribute for validwhen.


Assertion: validwhen only works with String and Integer fields

Problem: Trying to validate that a checkbox associated with a java.lang.Boolean type field in a dynamic form is checked.

A simple 'required' check always passes-- the field is always either true or false, so it has a value.

The request contains contactReportFlag? = on

The populated form bean is: DynaActionForm?[dynaClass=assignmentRequestForm?,contactReportFlag?=true {...} ]

Evidence:

No 'isInstance' checks for Boolean in [ValidWhenParser.g]

And nothing works:

struts-config.xml

      <form-bean name="assignmentRequestForm"
                 type="edu.asu.vpia.benweb.AssignmentRequestForm">
          <form-property name="contactReportFlag" type="java.lang.Boolean" initial="false"/>
          ...
      </form-bean>

validation.xml

            <!-- The Contact Report checkbox must be checked -->
            <field property="contactReportFlag" depends="validwhen">
                <arg key="label.investor.contact"/>
                <var>
                    <var-name>test</var-name>
                    <var-value>(*this* == 'true')</var-value>
                </var>
            </field>
Other tries
                     <var-value>(*this* == 'on')</var-value>

HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 31, 2006 8:49 am by WendySmoak (diff)
Search: