Remove the type="myBean" from your jsp and try 

Regards
Guru
 
------------------------------------------------------------------------
-----------
Gurumoorthy Raghupathy
Email  :  [EMAIL PROTECTED]
Internal Extn : 2337 
External Phone  : 01483712337 
Nielsen Book
3rd Floor Midas House
62 Goldsworth Road
Woking Surrey GU21 6LQ
Visit us at  : http://www.nielsenbookdata.co.uk/ 
------------------------------------------------------------------------
-----------
-----Original Message-----
From: Marcello Savino [mailto:[EMAIL PROTECTED] 
Sent: 04 April 2007 13:35
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to