Hi
I am trying to populate a list of objects using
struts 2.0 s:iterate tag with java.util.List in the Action. I am able to load populate the data from Action to the form but after submitting the form the List in the action is not getting updated with the new data.
My Action class is like this:
public class TestAction extends ActionSupport {
private List<Employee> empList;
public
String execute() throws Exception {
// after submitting i put break point here and checked the value of
// empList and the value is null
empList = new ArrayList<Employee>();
Employee emp1 = new Employee();
emp1.setCountry("1");
emp1.setName("amiya");
empList.add(emp1);
Employee emp2 = new Employee();
emp2.setCountry("2");
emp2.setName("gopal");
empList.add(emp2);
return SUCCESS;
}
public List getEmpList() {
return empList;
}
public void setEmpList(List<Employee> empList) {
this.empList = empList;
}
}
My form looks like this:
<s:form action="test">
<s:iterator value="empList">
<s:textfield name="name"></s:textfield>
</s:iterator>
<s:submit></s:submit>
</s:form>
What I need to change in the
jsp or action so that the List in the Action reflects the data submitted.