Here is a working example of nested properties in an iterator.

All I need is an indexed getter and setter for address in my testBean.( getAddress(int 
index) ) 


<% String propertyValue = null;%>
<logic:iterate id="address" name="testBean" property="addresses" 
indexId="addressIndex">
<tr>
  <td valign="top">
    Index #[<bean:write name="addressIndex"/>]
  </td>
  <td>
    <table border="0">
      <tr>
        <th>Street:</th>
        <td>
          <% propertyValue = "address[" + addressIndex + "].street"; %> 
          <html:text property="<%=propertyValue%>"/>
        </td>  
      </tr> 
      <tr>
        <th>Zip Code:</th>
        <td>
        <% propertyValue = "address[" + addressIndex + "].zipCode"; %> 
          <html:text property="<%=propertyValue%>"/>
        </td>  
      </tr> 
    </table>
  </td>
</tr>
</logic:iterate>

/Peter

 

-----Original Message-----
From: Torsten Terp [mailto:[EMAIL PROTECTED]]
Sent: den 1 juli 2001 20:01
To: Struts user list
Subject: Problems with iterate


Hi,

Sorry if this has been answered before, but i havent been able to find an answer!

Im using iterate to display a vector containg valueobjects, i.e., 

<html:form action="showContacts">
<logic:iterate id="contacts" name="form" property="contactDataVector">
<html:hidden name="contacts" property="contactId"/>
<tr>
  <td width="150">      
    <html:text name="contacts" property="firstName" size="20"/>
  </td>
  <td width="150">
    <html:text name="contacts" property="lastName" size="20"/>
  </td>
</tr>
...
...

'form' is my struts form bean, 'contactDataVector' is a vector of 'contactData'
objects each containing (among others) the variables 'firstName' and 'lastName'.

There is no problem in displaying the data, all goes well, but updating fields 
in the form is not working, when i want to save the changes in the struts action 
the vector is null! I can see that making a variable 'firstName' in the form, results
in a call to its setter method, i.e., i can make it work when updating a single row, 
but i cant manage to get the update to work on the actual contactData objects in the
vector. ?!?!

Any advices out there?? 

^terp

Reply via email to