File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes validwhen using indexedListProperty throwing NulPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validwhen using indexedListProperty throwing NulPointerException" Watch "validwhen using indexedListProperty throwing NulPointerException" New topic

validwhen using indexedListProperty throwing NulPointerException

K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
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>
<logic:iterate name="myForm" property="beanList"
id="beanList" indexId="i">
<%if (i.intValue()%2 == 0){%>
<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>

Here is my validation:

<field property="testCase" indexedListProperty="beanList" depends="validwhen">
<arg0 key="Test Case" resource="false"/>
<var-value>((editButton == null) or ((beanList[].testCaseOID == null) or (*this* != null)))</var-value>

And here is the exception I get when I try to load the page:

at org.apache.commons.validator.Field.getIndexedProperty(
at org.apache.commons.validator.Field.validate(
at org.apache.commons.validator.Form.validate(
at org.apache.commons.validator.Validator.validate(
at org.apache.struts.validator.ValidatorForm.validate(

I'm using this exactly the way the struts validator web site instructs. Please help me figure out what is wrong!
K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
Never mind, i figured it out. The validation was happening whe the page loaded, and the list had not yet been initialized. I made a separate action mapping for loading the page, and it worked.
I agree. Here's the link:
subject: validwhen using indexedListProperty throwing NulPointerException
It's not a secret anymore!