File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to use <logic:iterate> over arraylist of a bean class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use <logic:iterate> over arraylist of a bean class" Watch "How to use <logic:iterate> over arraylist of a bean class" New topic
Author

How to use <logic:iterate> over arraylist of a bean class

vivek mahajan
Greenhorn

Joined: Jun 18, 2009
Posts: 22
I have a Bean class like

and its getter and setter methods.Then in my execute method i m using this bean as

but i am unable to get this bean class in jsp page.The code i am using is as follows

please suggest me the modification or any alternate code.Thanks
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
You are almost there. Just think that your collection is not "myBean". It is something inside it.
For more refer this and this.


Experience and talent are independent of age
vivek mahajan
Greenhorn

Joined: Jun 18, 2009
Posts: 22
Himanshu Kansal wrote:You are almost there. Just think that your collection is not "myBean". It is something inside it.
For more refer this and this.


thanks for the suggestion
I changed the code but i m geting classCastException in the line where i wrote type="com.MyBean"
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
The "type" attribute gives the type of the objects contained in the collection. In other words, it should be the type of what you want to get by the bean specified by "id".

In your original example, I see Integer being added to the List and Integers only would be returned. "id" would give you those elements you added to the list, 1 in each iteration. The second link helps in understanding this.
Try to shoot the trouble now and get back if you need more help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use <logic:iterate> over arraylist of a bean class