I've gone through requiredif & validwhen in apache site. But, as our production release is struts 1.1, need to implement with requiredif until struts 1.2 goes into our prod.
Tried "requiredif" mentioned in apache, but of no luck. Only "required" validation is working, not getting why in the sameway "requiredif" is not working !!!
I am using Tomcat 4.1
here is my validations.xml
<field property="age" depends="required">
<arg0 key="label.age"/>
</field>
<field property="name" depends="requiredif">
<arg0 key="label.name"/>
<var>
<var-name>field[0]</var-name>
<var-value>age</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>NOTNULL</var-value>
</var>
</field>
[ I have tried for NOTNULL and also NULL]
here is the form-bean
<form-bean name="TestForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="age" type="java.lang.String" />
<form-property name="name" type="java.lang.String" />
<form-property name="submit" type="java.lang.String" />
</form-bean>
jsp <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:form action="MedicalAction" onsubmit="return validateTestForm(this)" >
<html:text property="age" value="" />
<html:text property="name" value="" />
<html:submit property="submit" value="sbt" />
</html:form>
<html:javascript formName="TestForm"/>
Here required validation for 'age' is working fine, But 'name' is not being validated for "requiredif".
I have seen the html page generated, it doesn't have the javascript code for "name".
I am not sure - why required validation is working and why in the sameway requiredif is not working.
Any kind of guess is also thankful.
thanx in advance.