This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
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

Not able to specify path for form:select tag with list of objects...

 
Anoop Nair
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a doubt when using Spring.

I have a model class (A) which has a list of objects of another class (B).
In my JSP, I have to iterate over this list of objects.
I am trying to set the path attribute of a select box during the iteration. The path is a member of class B.
For each iteration, I have to refer to the member of the corresponding object only. I am not able to figure out how to specify this in JSP.

Below is a snippet of the model class and also the JSP. Also I have mentioned two things which I tried.


Model class:



JSP:





Below are the two approaches I tried:
1. Set the path as just a string as in above example.
In this case, Spring looks for a member with the name of the iteration variable (specialGroups in my case) in the model class. And since its not able to find one, it throws error.

2. Set the path by ${specialGroups.specialGroupId}
In this case, the value in the EL got evaluated. Spring then looks for a member having the name as the EL value. Again, in this case it throws error as there is no field with that name.
 
Anoop Nair
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it working by using below tag

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic