• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

multibox - nullPointerException

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic