Cameron,

Are you sure that your request attributes are named that way?  I read that
as a 3 dimensional table...do you really have that in your page?

If you are getting those request attributes, then I'm stumped, but I'd love
to know the answer :-)

Otherwise...you need a getter/setter for the collection which get s and
sets a collection of "bean" objects.  You also need a get method for a
single element in your indexed collection.  For example:

public Collection getIps() {return ips;}
public void setIps(ArrayList ips) {this.ips = ips;}

public ItemProperties getIp(int index) {
  while (index >= ips.size()) {
    ips.add(new ItemProperties());
  }
  return (ItemProperties)ips.get(index);
}

Nick



                                                                                       
                                                
                      "Cameron Hickey"                                                 
                                                
                      <[EMAIL PROTECTED]        To:       "'Struts Users Mailing 
List'" <[EMAIL PROTECTED]>                
                      com>                     cc:                                     
                                                
                                               Subject:  writing an actionform for 
nested indexed properties                           
                      08/21/2003 10:00                                                 
                                                
                      AM                                                               
                                                
                      Please respond to                                                
                                                
                      "Struts Users                                                    
                                                
                      Mailing List"                                                    
                                                
                                                                                       
                                                
                                                                                       
                                                




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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to