For this, you will need to use "indexed properties". It takes a bit of effort to learn how to use them. The best place to start would be this link in the JavaRanch Struts FAQ Pay special attention to the example application that is shown there.
[3/18/07 11:17:14:188 PST] 00000049 WebApp E SRVE0026E: [Servlet Error]-[/web/services/servicePackage.jsp]: java.lang.NullPointerException at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:1162) at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:772) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801) at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:952) at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:277)
I'm totally lost. PleAse Help!!!
Joined: Feb 15, 2005
If all you want to do is display information using <bean:write> tags, then you are right: you don't need indexed properties for that. However, if you want to input values from a list of objects then you do need to use indexed properties. Since your first post contained an example of an input control using a property in a list, that's why I suggested indexed properties.
Regarding your second example: The code in the JSP looks correct. I suspect the problem is that your objects are not properly populated prior to the JSP being displayed. If the getPackageCBO method on any of the PackageDTO objects in the list returns null, that would cause this problem. [ March 18, 2007: Message edited by: Merrill Higginson ]