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>
True. The bundled validator-rules.xml file has no 'jsFunction' attribute for validwhen.
Problem: Trying to validate that a checkbox associated with a java.lang.Boolean type field in a dynamic form is checked.
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>