| Author |
Trouble with indexed properties
|
Martin Riedl
Greenhorn
Joined: Sep 06, 2003
Posts: 7
|
|
i know that this topic has been discussed earlier and i already have one version of indexed properties on another jsp that runs - but this time i have serious trouble. I have an ActionForm-Bean which contains a String-Array of Beans. ----CODE---- private ListBean[] beans; private ListBean bean; public ListBean[] getBeans() { return beans; } public void setBeans(int index, ListBean bean) { beans[index] = bean; } public void setBean(int index, ListBean value) { beans[index] = value; } public ListBean getBean(int index) { return (ListBean) beans[index]; } --Code end This code in my jsp look like: <html:form action="list.do?method=copy" > <table width="400" border="0" > <logic:iterate id="speech" indexId="ctr" name="CopyListFormBean" property="beans" type="istd.client.td.beans.ListBean" > <tr> <td width="20%"> <html:checkbox property='<%= "beans[" + ctr + "].copy" %>' /> </td> <td> <bean:write name="CopyListFormBean" property='<%= "beans[" + ctr + "].sprache" %>' /> <html:hidden property='<%= "beans[" + ctr + "].sprachId" %>' /> <html:hidden property='<%= "beans[" + ctr + "].listId" %>' /> </td> </tr> </logic:iterate> <tr> <td> </td> <td> <html:submit /> </td> </tr> </html:form> When Submitting the Form i get the 'popular' ErrorMessage java.lang.NullPointerException at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:497) at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:410) at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:749) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:780) at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726) Any Idea? I'm totally frustrated - maybe i need a break.
|
 |
Priya Selvaraj
Greenhorn
Joined: Mar 27, 2002
Posts: 4
|
|
I had the same problem. I solved it by initializing the phone array in the setter method. For Example: private String[] phone = null; public void setPhone(int index, String value) { try { if(phone==null) { phone = new String[100]; } phone[index]=value; } catch (Exception e) { System.out.println("Exception in setPhone : " + e);} } Thanks Priya
|
 |
 |
|
|
subject: Trouble with indexed properties
|
|
|