wood burning stoves 2.0*
The moose likes Struts and the fly likes Logic:iterator issue in Struts 1.3.10 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Logic:iterator issue in Struts 1.3.10" Watch "Logic:iterator issue in Struts 1.3.10" New topic
Author

Logic:iterator issue in Struts 1.3.10

Sri Ram
Greenhorn

Joined: Feb 13, 2006
Posts: 20
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>
Nawaz Ijaz
Greenhorn

Joined: Nov 25, 2008
Posts: 10
Hello Sri Ram,

We are migrating to Struts v1.3.10 from Struts v1.3.8.

I did not face the problem which you have mentioned in your post above. Could you please tell me what was the actual problem and how did you produce that? and how did you solved that problem??

So far it seems like a smooth migration activity. We are not facing any issue in our local environment?

can you tell me if there is/are any other issue(s) that we can face after migrating to Struts v1.3.10 from Struts v1.3.8?

Thanks and Kind Regards,
Nawaz
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Logic:iterator issue in Struts 1.3.10