• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

validwhen using indexedListProperty throwing NulPointerException

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
K Dombroski
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic