I am new to Struts 1.x. I need to iterate List<List<VO>>
in a JSP using <logic: iterate>
List<List<VO>>
-- defined in Form
from that I am able to get and Outer List. Now using an id, I get the inner list. My List<Vo>
used to fill the combo-boxes.
How do I get the properties of VO from <logic:iterate>
?
It's been a while since I used Struts 1.x, but IIRC you should be able to access the VO from inside a <logic:iterate>
.
Assuming you have something like this in your Action (PersonForm
is the VO, and it contains a list of email addresses):
List<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
emailAddresses.add(new EmailAddress("bob@bob.com"));
emailAddresses.add(new EmailAddress("bob@somewhere-else.com"));
PersonForm personForm = new PersonForm();
personForm.setFirstName("Robert");
personForm.setEmailAddresses(emailAddresses);
request.setAttribute("myPersonForm", personForm );
And then the following in your JSP:
<logic:iterate name="myPersonForm" property="emailAddresses" id="email">
<li><bean:write name="myPersonForm" property="firstName" /></li>
<li><bean:write name="email" property="address"/></li>
</logic:iterate>
That should print out something like: