Hi,
We are working with struts 2.0.14 and facing problem setting back indexed properties from JSP to action class.
Code looks similar to this.
public class MyExample extends ActionSupport
{
private List<Person> persons;
private List<String> names;
public String execute()
{
//persons = myDAO.readPersons(names);
return SUCCESS;
}
public String update()
{
for (Person p : persons)
{
System.out.println(p.getName() + "---" + p.getAddress().getStreet());
}
return SUCCESS;
}
// Getters and setters
}
class Person
{
private Address address;
private String name;
// Getters and setters
}
class Address
{
private String street;
private String number;
// Getters and setters
}
And JSP:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<!---- Other code ---->
<s:ieterate value="persons" status="status">
<tr>
<s:textfield name="person['%{#status.index}'].name"/>
<s:textfield name="person['%{#status.index}'].address.number"/>
<s:textfield name="person['%{#status.index}'].street"/>
</tr>
I could successfully display values onto the page, but when i submit the form the values are not getting populated. I checked firebug to see how the parameters are posted and they are like person['0'].name, person['0'].address.number etc., Please let me know where the mistake lies.