You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Levan Dvalishvili <dv...@verticali.com> on 2007/04/04 15:31:37 UTC
unsibscribe
unsubscribe
-----Original Message-----
From: Marcello Savino [mailto:Marcello.Savino@aldebra.com]
Sent: Wednesday, April 04, 2007 8:35 AM
To: Struts Users Mailing List
Subject: Iterating over a List of JavaBean
Hi all,
In a jsp file i need to iterate over an ArrayList of javabean :
The bean:
public class myBean implements java.io.Serializable{
private Integer code;
private String name;
public Integer getCode(){return code;}
public String getName(){return name;}
public void setCode(Integer val){ code=val;}
public void setName(String val){ name=val;}
}
In the action class i set the form.list variable:
...
public ActionForward list(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
try {
myBean[] l;
l=getMyBeanArray();
((ActionFormBase)form).list=new
ArrayList();
for (int i=0;i<l.length;i++){
((ActionFormBase)form).lista.add(l);
}
request.setAttribute("lista",
((ActionFormBase)form).lista);
} catch (Exception e){
((ActionFormBase)form).ErrMessage=e.getMessage() ;
}
return(mapping.getInputForward() );
}
...
And this is my jsp code:
...
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
...
<logic:iterate id="index" name="lista" type="myBean">
<bean:write name="index" property="code"/>
<bean:write name="index" property="name"/>
</logic:iterate>
But what i get is an Exception:
java.lang.ClassCastException: [LmyBean;
Any help will be greatly appreciated.
Thanks in advance
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org