I am trying to validate fields in a table. When one field is present, I need to ensure that the other fields in that row are present. Here is my
jsp:
<logic:notEmpty name="myForm" property="beanList">
<table class="basic-table">
<TR class="blue-med-table">
<th><bean:message key="label.testcasename" /></th>
<th><bean:message key="label.duration" /></th>
</TR>
<logic:iterate name="myForm" property="beanList"
id="beanList" indexId="i">
<%if (i.intValue()%2 == 0){%>
<tr>
<%}else{%>
</tr>
<tr class="even">
<%}%>
<TD><html:hidden name="beanList" property="testCaseOID"
indexed="true" /> <html:text name="beanList" property="testCase"
size="30" maxlength="128" onchange="trimString(this)"
indexed="true" /></TD>
<TD><html:text name="beanList" property="duration" size="3"
maxlength="3" onchange="trimString(this)" indexed="true" /></TD>
</tr>
</logic:iterate>
</table>
</logic:notEmpty>
Here is my validation:
<field property="testCase" indexedListProperty="beanList" depends="validwhen">
<arg0 key="Test Case" resource="false"/>
<var>
<var-name>
test</var-name>
<var-value>((editButton == null) or ((beanList[].testCaseOID == null) or (*this* != null)))</var-value>
</var>
</field>
And here is the exception I get when I try to load the page:
java.lang.NullPointerException
at org.apache.commons.validator.Field.getIndexedProperty(Field.java:796)
at org.apache.commons.validator.Field.validate(Field.java:891)
at org.apache.commons.validator.Form.validate(Form.java:174)
at org.apache.commons.validator.Validator.validate(Validator.java:367)
at org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:110)
I'm using this exactly the way the
struts validator web site instructs. Please help me figure out what is wrong!