Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 polymorphic list in select tag

 
Tony Manello
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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!
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic