Have you tried the nested tags on this?

<html:form ...>
  <nested:iterate property="beans">
    <nested:text property="foo"/>
  <nested:iterate/>
</html:form>

For the form class, the JavaBeans pattern for an indexed property is the following:

public void setter(int index, PropertyType value);
public PropertyType getter(int index);
public void setter(PropertyType[] values);
public PropertyType[] getter();

For Struts, since it leverages BeanUtils, you can shorthand it to:

public void setter(List values);
public List getter();

I'm not really sure you're exposing the properties you think you are because
you're using inconsistent method names (getBeans and getBean) as well as
property types (Object[], ArrayList, and NestedBean).

Quoting Mark Lowe <[EMAIL PROTECTED]>:

> Has anyone else had any problems setting nested bean values
> 
> Here's and example of what i mean..
> 
> public class DemoForm extends ActionForm {
> 
>       private ArrayList beanList;
> 
>       public DemoForm() {
>               this.beanList = new ArrayList();
>       }
> 
>       public Object[] getBeans() {
>               return beanList.toArray()
>       }
>       
>       public void setBeans(ArrayList beanList) {
>               this.beanList = beanList;
>       }
>       
>       public NestedBean getBean(int i) {
>               NestedBean bean = (NestedBean) beanList.get(i);
>               return bean;
>       }
> //and so on
> }
> 
> ..
> 
> public class NestedBean {
>       private String foo;
> 
>       public String getFoo() {
>               return foo;
>       }       
>       
>       public void setFoo(String foo) {
>               this.foo = foo;
>       }
> }
> 
> ..
> <c:forEach var="bean" items="${myForm.beans}">
>       <html:text name="bean" property="foo" indexed="true" />
> </c:forEach>
> 
> The problem comes when i change values in the form element the values 
> dont change  so i guess the jsp and the servlets aren't interacting. I 
> work around by retrieving form the parameter map
> 
> String target = "bean["+ i +"].foo";
> String value = request.getParameter(target).toString();
> 
> 
> This works okay , but I'd really like to know wether i can do this 
> without this hack.
> 
> Cheers Mark

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

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

Reply via email to