Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
vivek mahajan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are almost there. Just think that your collection is not "myBean". It is something inside it.
For more refer this and this.
 
vivek mahajan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic