You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cameron Hickey <ca...@panoramatos.com> on 2003/08/21 16:00:28 UTC
writing an actionform for nested indexed properties
I am trying to write an actionform which will properly handle an array
of indexed properties which look like this:
ip[0].itemPropertys[0].itemPropertyId
ip[0].itemPropertys[0].value
ip[1].itemPropertys[0].itemPropertyId
ip[1].itemPropertys[0].value
etc...
In my Action form, what getters and setters do I need?
This is what I have so far:
public List getIp() { return ip;}
public void setIp(List ipList) {ip = ipList;}
public List getItemPropertys(int idx) {return (List) ip.get(idx); }
public void setItemPropertys(int idx,ItemProperty ipe)
{ip.set(idx,ipe);}
public ItemProperty getItemProperty(int idx, List ipl) {return
(ItemProperty) ipl.get(idx);}
public void setItemProperty(int idx,List ipl, ItemProperty tip)
{ipl.set(idx,tip);}
public String getValue(ItemProperty tip) {return tip.getValue();}
public void setValue(String s, ItemProperty tip) {tip.setValue(s);}
public int getItemPropertyId(ItemProperty tip) {return
tip.getItemPropertyId();}
public void setItemPropertyId(int i, ItemProperty tip)
{tip.setItemPropertyId(i);}
but when I try to submit the form, I get this error:
<ERROR>
java.lang.NullPointerException
at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUt
ils.java:497)
at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUt
ils.java:410)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUti
ls.java:729)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.jav
a:780)
at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:793)
at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:726)
</ERROR>
which I assume is coming from the fact that I don't have all the right
getters and setters available, since it must be trying to call one that
does not exist (thus the null pointer).
Is this right?
Should I have other getters and setters?
THANKS FOR ANY HELP!!
Cameron
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org