Hi,
I am using a form that contains a collection of objects. I am using logic:iterate and html:text to iterate over it.
I use the same form for editing and submitting.
When I come to the editing page, it is reading the values from the collection of objects correctly. But when I change values and resubmit, the collection is returned as empty in my action.
I am attaching action, form and
jsp here. Any help will be greatly appreciated.
Thanks in advance
Karthik
The jsp initially populates with 6 rows as expected from the following code
PopulateJSPAction{
for (int i = 0; i < 6; i++) {
ProfessionalServiceDTO professionalServiceDTO = new ProfessionalServiceDTO();
professionalServiceCollection.add(professionalServiceDTO);
}
}
JSP :
*************
<html:form name = "editHCFA1500Form".....>
<logic:iterate name = "editHCFA1500Form" id = "serviceCollection" property="professionalServiceCollection" type="com.h2hsolutions.database.hcfacms.beans.ProfessionalServiceDTO">
<html:text name = "serviceCollection" property="serBegDate" size="4"/>
</html:form>
Form Bean:
*******************
public class EditHCFA1500Form extends ActionForm
{
/**
*
*/
private static final long serialVersionUID = 1L;
private ArrayList professionalServiceCollection = new ArrayList();
public ArrayList getProfessionalServiceCollection() {
return professionalServiceCollection;
}
public void setProfessionalServiceCollection(
ArrayList professionalServiceCollection) {
this.professionalServiceCollection = professionalServiceCollection;
}
//There is also an indexed getter method as reqd by
struts public ProfessionalServiceDTO getProfessionalServiceCollection(int index) {
return (ProfessionalServiceDTO)professionalServiceCollection.get(index);
}
Action Class:
**********************
execute(....){
ArrayList professionalServiceCollection = editHCFA1500Form.getProfessionalServiceCollection();
System.out.println("Collection size = "+professionalServiceCollection.size());
}
The output is coming as Collection size = 0;