Hi all,
I have a problem using iterate tag.
I have foll files:
ListUserForm.java
public void setUserArray(ArrayList userArray)
{
this.userArray=userArray;
}
public ArrayList getUserArray()
{
return this.userArray;
}
UserDetails.java
public String getUserName()
{
return this.userName;
}
public void setUserName(String userName)
{
this.userName=userName;
}
public String getUserAge()
{
return this.userAge;
}
public void setUserAge(String userAge)
{
this.userAge=userAge;
}
public String getUserAddress()
{
return this.userAddress;
}
public void setUserAddress(String userAddress)
{
this.userAddress=userAddress;
}
ListUserAction.java
ActionForward uri=null;
HttpSession session = null;
UserDetails ud=new UserDetails();
ArrayList userArray=new ArrayList();
ListUserForm listUserForm=(ListUserForm)form;
ud.setUserName("abc");
ud.setUserAge("56");
ud.setUserAddress("df");
userArray.add(ud);
//listUserForm.setUserArray(userArray);
ud.setUserName("def");
ud.setUserAge("561");
ud.setUserAddress("df1");
userArray.add(ud);
//listUserForm.setUserArray(userArray);
ud.setUserName("xyz");
ud.setUserAge("562");
ud.setUserAddress("df2");
userArray.add(ud);
listUserForm.setUserArray(userArray);
uri=(mapping.findForward("success"));
ListUser.jsp
<%@page import="java.util.*"%>
<%@page import="org.apache.struts.action.ActionError"%>
<%@page import="org.apache.struts.action.ActionErrors"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE></TITLE>
</HEAD>
<BODY>
<table border=0>
<tr>
<td>Name</td>
<td>Age</td>
<td>Address</td>
</tr>
<logic:iterate offset="0" id="abs" name="listUserForm"
type="UserDetails" property="userArray" scope="request">
<tr>
<td><bean:write name="abs" property="userName" /></td>
<td><bean:write name="abs" property="userAge" /></td>
<td><bean:write name="abs" property="userAddress" /></td>
</tr>
</logic:iterate>
</table>
</BODY>
</HTML>
</html:html>
My Problem:
In my jsp page I get to see xyz thrice. How do I see all the values in my
ArrayList...??
-------anjali
Power your enterprise with custom solutions in eLearning and Knowledge
Management from NIIT - Knowledge Solutions. For details visit our website
http://www.ksb.niit.com
___________________NOTICE____________________________
This electronic mail transmission contains confidential information intended
only for the person(s) named. Any use, distribution, copying or disclosure
by any other person is strictly prohibited. If you received this
transmission in error, please notify the sender by reply e-mail and then
destroy the message. Opinions, conclusions, and other information in this
message that do not relate to the official business of NIIT shall be
understood to be neither given nor endorsed by NIIT When addressed to NIIT
clients, any information contained in this e-mail is subject to the terms
and conditions in the governing client contract.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>