The problem is, the generated names of the HTML form elements do not
correspond to the names of properties of your ActionForm.

Here a sample, how this can be done:

  <logic:iterate name="myForm" property="elements" id="element" indexId="i"
     type="de.grayman.test.struts.MyElement">
    <tr>
      <td>
        <html:checkbox property='<%= "element[" + i + "].member" %>'  />
        <html:hidden property='<%= "element[" + i + "].elementName" %>'  />
      </td>
      <td><bean:write name="element" property="elementName" /></td>
      <td><bean:write name="element" property="elementDescription" /></td>
    </tr>
  </logic:iterate>


In the MyForm class, there have to be two properties (getter methods):

1) the collection "elements"
2) indexed property "element"

private Vector elements;

public Collection getElements() {
    return this.elements;
}

public MyElement getElement(int i) {
   while (getGroups().size() <= i) {
       this.element.add(new MyElement());
   }
   return (MyElement) this.elements.get(i);
}


Note: Class MyElement has read/write properties member, elementName,
elementDescription, ...

Note: The getElement(int i) fills the Vector with empty elements, if they do
not exist.
In this way, the form will be filled correcly from the submitted HTML-Form. Of
course,
you could use another approach, e.h. HashTable or an Array instead of Vector.

--
gR


----- Original Message -----
From: "Vaibhav Patil" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 2:02 PM
Subject: Iterate tag update


> Hi,
>     I am using logic:iterate tag as follows to print a table with text
> boxes.
>
>         <logic:iterate id="product" name="productSearchForm"
> property="productList">
>         <tr>
>           <td align="left">
>             <bean:write name="product" property="productNumber"
> filter="true"/>
>           </td>
>           <td align="center">
>             <html:text name="product" property="quantity" size="3"/>
>           </td>
>         </tr>
>         </logic:iterate>
>
> I have a array of objets(Product) in productList. When I update the quantity
> and submit the page, it does not update the information into the
> productList.
>     What might be the problem???
>
> Vaibhav
>

Reply via email to