Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multibox - nullPointerException

 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,
I'm trying to use a multibox for the first time in Struts and am receiving a nullpointerexception when displaying the jsp page:

ApplicationDispatcher[/scmiteam] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.struts.util.BeanUtils.getArrayProperty(BeanUtils.java:217)
...

my jsp code looks like this:
<logic:iterate id="myElem" name="listBean" property="collection" type="org.something.bean.dto.QuickLinkBean">
<tsegui:row oddColor="#eeeeee" evenColor="#dedede">
<td class="box">
<bean:write name="myElem" property="id"/>
</td>
<td class="box">
<html:multibox styleClass="transparent" property="strArray">
<bean:write name="myElem" property="id"/>
</html:multibox>
</td>
<td class="box link" width="300">
<tsegui:link forward="getQuickLink" paramId="id" paramName="myElem" paramProperty="id">
<bean:write name="myElem" property="title"/>
</tsegui:link>
</td>
</tsegui:row>
</logic:iterate>
it should also be noted that when i assign the property attribute to another item that isn't in the same formBean i get a 'getter method not found' error. which makes sense because like i said, it ISN'T in the form. i just state this to show that it does indeed seem to be accessing the getStrArray() method from the correct formBean, but only coming up null somehow.
i've also written out my array just after setting it and it does indeed contain the four items i've assigned to it.
any ideas?
thanks!
b
 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i love posting to forums because within 20 minutes of my post i always figure out my own problem.
anyway, what was happening...is that i was initializing the strArray to, let's say 8, but only filling it with 4 items. therefore when my iterate tag got to the strArray[4] it was trying to access a NULL value.
so simple.
hope this helps someone else!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic