• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts2 polymorphic list in select tag

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All, I have a list with several inherited objects so the List is defined with the parent object (it's defined as abstract) as parameter. In the prepare() method of the action I retrieve from DB all the child objects and I add them to the List<Parent> list. It works ok until I use that list in a select tag. Then it throws a npe exception. What am I doing wrong?

Thanks in advance!
 
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how are you using the list in the jsp? Some code might help
 
Tony Manello
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I think I use the list as usual:

Snippets:

Action:

Ejercicio is the parent class (abstract) and child classes are Estiramientos, Pesas, Progresivos, Serie, CarreraContinua, CambiosRitmo.

List<Ejercicio> listaEjercicios is the parent's objects list containing all child objects. I have split in several child's lists just as a matter of retrieving listaEjercicios sorted by the child's type.



JSP:



Any advice?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic