I have a form in which I'd like to enter several rows (5 at a time) of information. 5 blank rows get displayed as expected but when I try to submit the information as a user, I am only getting back the values for the first row and nothing seems to get set for the other 4 rows even though there were values set in the browser. Not sure what's wrong. Does any one have any suggestions on what could be causing this?
The jsp code is:
<html:form action="AddEmployees.do">
<logic:iterate name="AddEmployeesForm" property="employees" id="row" scope="request">
Name: <html:text name="row" property="name" size="50" maxlength="120"/>
Email: <html:text name="row" property="email" size="50" maxlength="120"/>
<html:submit/>
</logic:iterate>
</html:form>
The action, AddEmployees.do is mapped to the AddEmployeesForm. It looks like:
public final class AddEmployeesForm extends ActionForm
{
private ArrayList m_employees = new ArrayList();
private Log m_log = LogFactory.getLog(this.getClass());
public AddEmployeesForm()
{
addEmployee(new NewEmployee());
addEmployee(new NewEmployee());
addEmployee(new NewEmployee());
}
public List getEmployees() { return m_employees; }
public void setEmployees(ArrayList employees) { m_employees = employees; }
public void setName(String name)
{
m_log.info("setName: " + name);
}
public void setEmail(String email)
{
m_log.info("setEmail: " + email);
}
public void addEmployee(NewEmployee employee)
{
m_employees.add(employee);
}
public int getSize() { return m_employees.size(); }
}
and NewEmployee is a separate class with name and email as properties with public getters and setters:
public class NewEmployee
{
private String m_name = new String();
private String m_email = new String();
public NewEmployee()
{
}
public String getName() { return m_name; }
public void setName(String name) { m_name = name; }
public String getEmail() { return m_name; }
public void setEmail(String email) { m_email = email; }
}
Thanks,
Justin
The jsp code is:
<html:form action="AddEmployees.do">
<logic:iterate name="AddEmployeesForm" property="employees" id="row" scope="request">
Name: <html:text name="row" property="name" size="50" maxlength="120"/>
Email: <html:text name="row" property="email" size="50" maxlength="120"/>
<html:submit/>
</logic:iterate>
</html:form>
The action, AddEmployees.do is mapped to the AddEmployeesForm. It looks like:
public final class AddEmployeesForm extends ActionForm
{
private ArrayList m_employees = new ArrayList();
private Log m_log = LogFactory.getLog(this.getClass());
public AddEmployeesForm()
{
addEmployee(new NewEmployee());
addEmployee(new NewEmployee());
addEmployee(new NewEmployee());
}
public List getEmployees() { return m_employees; }
public void setEmployees(ArrayList employees) { m_employees = employees; }
public void setName(String name)
{
m_log.info("setName: " + name);
}
public void setEmail(String email)
{
m_log.info("setEmail: " + email);
}
public void addEmployee(NewEmployee employee)
{
m_employees.add(employee);
}
public int getSize() { return m_employees.size(); }
}
and NewEmployee is a separate class with name and email as properties with public getters and setters:
public class NewEmployee
{
private String m_name = new String();
private String m_email = new String();
public NewEmployee()
{
}
public String getName() { return m_name; }
public void setName(String name) { m_name = name; }
public String getEmail() { return m_name; }
public void setEmail(String email) { m_email = email; }
}
Thanks,
Justin