I am using Struts1.3, I have Jsp page which is showing the list of employees on that page. For this what i did is, I have a action inside that action i am calling a function which returns List and i am setting these list inside the session as session.setAttribute(Constant.EMPLIST,list). And now in my Jsp page i am using logic tag to iterate this list as below given.
<html:form method="post" action="test.do" styleId="empForm">
<logic:iterate id="EmpForm" name="<%=Constant.EMPLIST%>">
<table>
<tr>
<td>
<html:text property="empName" name="EmpForm" styleClass="fieldbox2" styleId="textfield50"/>
</td>
<td>
<html:text property="empSal" name="EmpForm" styleClass="fieldbox3" styleId="textfield50"/>
</td>
</table>
</logic:iterate>
<table>
<tr>
<td>
<img onclick="updateEmpDetails" src="images/update.jpg" />
</td>
</tr>
</table>
</html>
And it's showing all the employee details and working fine. But one more job is that on this page i have a update
button. And what i need to do is after clicking on updateEmpDetails
button. I need to send all the employee updated details inside the updateAction but I am unable to do this, I don't know how to handle the multiple FormBean property value. I am able to fetch only one Employee details inside the updateAction. I am doing this inside my updateAction
EmpForm empForm = (EmpForm) form;
System.out.println("EmpId:::" + empForm.getEmpId);
I don't know how to do this if possible List Or how to handle multiple FormBean Value. please guide me how to do this,if any example please it really appreciate me. Thanks
Update:: This is my plan java class with setter and getter property:
public class Sites {
private String jobSite="";
private String engineerName="";
private boolean isCheck;
}
This is my FormBean:
public class SiteToServiceForm extends org.apache.struts.action.ActionForm {
private List<Sites> sites=new ArrayList<Sites>();
public List<Sites> getSites() {
return sites;
}
public void setSites(List<Sites> sites) {
this.sites = sites;
}
}
This is my action:
public class SiteToServicingAction extends org.apache.struts.action.Action {
List<Sites> siteDetails=SiteSearchDataModel.getSiteDetails(serviceForm);
((SiteToServiceForm) form).setSites(siteDetails);
}
For display purpose working fine now i need to submit the update sites value, I am doing this inside action:
List<Sites> siteList=serviceForm.getSites();
if(siteList!=null && siteList.size()>0)
{
for(Sites site:siteList)
{
if(site.isIsCheck()==true)
{
SiteSearchDataModel.updateRecord(serviceForm.getEngineerId(), site.getPropertyId());
System.out.println("properyID::::"+site.getPropertyId());
}
}
}
And i am not able to get the update list into my action class please help me.