• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

validwhen using indexedListProperty throwing NulPointerException

Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
<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(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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
I was born with webbed fish toes. This tiny ad is my only friend:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic