I am initially displaying data from the form which has a list of RoleVO like
package com.web;
import java.util.ArrayList;
import java.util.List;
import org.apache.struts.validator.ValidatorForm;
import com.vo.RoleVO;
public class ManageRoleForm extends ValidatorForm {
//Search Details of the User
private RoleVO searchRoleDetails= new RoleVO();
//ArrayList of the Search Result Roles
private List roleResults=new ArrayList();
public RoleVO getSearchRoleDetails() {
return searchRoleDetails;
}
public void setSearchRoleDetails(RoleVO searchRoleDetails) {
this.searchRoleDetails = searchRoleDetails;
}
public List getRoleResults() {
return roleResults;
}
public void setRoleResults(List roleResults) {
this.roleResults = roleResults;
}
public void reset() {
if (this.roleResults != null) {
RoleVO roleVO = null;
for (int i = 0; i < roleResults.size(); i++) {
roleVO = (RoleVO) roleResults.get(i);
roleVO.setValueSelected("N");
}
}
}
}
I use DispatchAction like
package com.web;
import java.util.List;
import java.util.ListIterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.catalina.Session;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.bao.AdminBAO;
import com.IAdminBAO;
import com.vo.RoleVO;
public class ManageRoleAction extends DispatchAction {
public ActionForward searchRoles(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// Getting the Manage User form
ManageRoleForm manageRoleForm = (ManageRoleForm) form;
RoleVO searchRoleVO = manageRoleForm.getSearchRoleDetails();
IAdminBAO adminBAO = new AdminBAO();
manageRoleForm.setRoleResults(adminBAO.searchRole(searchRoleVO));
return mapping.findForward("searchResults");
}
public ActionForward deleteRoles(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// Getting the Manage User form
HttpSession session = request.getSession();
ManageRoleForm manageRoleForm = (ManageRoleForm)form;
List searchRoleVO = manageRoleForm.getRoleResults();
System.out.println(searchRoleVO.size());
ListIterator iterator = searchRoleVO.listIterator();
RoleVO roleVO = null;
while (iterator.hasNext()) {
roleVO = (RoleVO) iterator.next();
System.out.println(roleVO.getValueSelected());
System.out.println(roleVO.getRoleID());
}
// Call the Service to get the Search Results
// Modify this
return mapping.findForward("searchResults");
}
}
package com.vo;
import java.io.Serializable;
import java.util.Date;
public class RoleVO implements Serializable {
// Role ID of the User
private
String roleID;
// Role Name of the User
private String roleName;
// Status of the User
private String status;
// No of Users
private String noOfUsers;
// Updated By
private String updatedBy;
// Updated On
private Date updatedOn;
// isSelected attribute
private String valueSelected="N";
public String getRoleID() {
return roleID;
}
public void setRoleID(String roleID) {
this.roleID = roleID;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getNoOfUsers() {
return noOfUsers;
}
public void setNoOfUsers(String noOfUsers) {
this.noOfUsers = noOfUsers;
}
public String getUpdatedBy() {
return updatedBy;
}
public String getValueSelected() {
return valueSelected;
}
public void setValueSelected(String valueSelected) {
this.valueSelected = valueSelected;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
}
I am unable to edit the value of text box in the
jsp <logic
resent name="manageRoleForm" property="roleResults" >
<logic:iterate id="roles" name="manageRoleForm"
property="roleResults" type="com.vo.RoleVO" >
<tr>
<td>
<div align="center"><font color="#008000"><a
class="marln" href="ModifyRole.htm"><bean:write name="roles" property="roleID" /></a> </font></div>
</td>
<td>
<div align="center"><font color="#008000"><bean:write name="roles" property="roleName" /> </font></div>
</td>
<td>
<div align="center"><font color="#008000"><bean:write name="roles" property="status" /> </font></div>
</td>
<td>
<div align="center"><font color="#008000"><bean:write name="roles" property="noOfUsers" /></font></div>
</td>
<td>
<div align="center"><font color="#008000"><bean:write name="roles" property="updatedBy" /></font></div>
</td>
<td>
<div align="center"><font color="#008000">10/02/2008
10:21:12</font></div>
</td>
<td>
<div align="center"><html:text name="roles"
property="valueSelected" indexed="true"> </html:text>
</div>
</td>
</tr>
</logic:iterate>
</logic
resent>