It's not a secret anymore!
The moose likes Spring and the fly likes Help needed to indicate " title="Thanksgiving" /> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Help needed to indicate "selected" for <form:select> <form:option/>" Watch "Help needed to indicate "selected" for <form:select> <form:option/>" New topic

Help needed to indicate "selected" for <form:select> <form:option/>

laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
Hi Everyone,

I can't figure out how to show that a value is "selected" on an option list. I know that "selected" is not supported and that the "path" should be bound to the value. I'm not sure what this entirely means but I thought in my controller if I set the value of the "path" it would automagically be set within the form. But, because I am doing something a little less than normal I'm figuring that I have something messed up. This is what I have do far:

Here's a snippet of my controller.

Here is my jsp page:
The path "movieid" corresponds to the MovieTimeslot id for the MovieTimeslot object which contains the timeslotid, movieid, showtime, theaterId. So, I don't know how to show that one of my movie options is "selected" based on my controller which finds the movie object if an editId exists.

Any suggestions would be appreciated.

laura mccord
Ranch Hand

Joined: Feb 10, 2009
Posts: 108
What I found worked for me was to change things around in my jsp nd use the <spring:bind> tag instead of <form> tags

<spring:bind path="movieid">
<select name="movieid">
<c:forEach items='${movies}' var='movie'>
<c:when test="${ eq timeslotid}">
<option value="${}" selected="true">${movie.title}</option>
<option value="${}">${movie.title}</option>
I agree. Here's the link:
subject: Help needed to indicate "selected" for <form:select> <form:option/>
jQuery in Action, 3rd edition