aspose 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to use <logic:iterate> over arraylist of a bean class
 
Similar Threads
Setting the valus of variable present in an Arraylist which is present in another arraylist
Cannot find bean: "sendJsp" in any scope
logic:equal comparison against int data type
Not able to iterate through a bean property of type Array List
Urgent: How to use Indexed Properties