Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic