Announcement Announcement Module
Collapse
No announcement yet.
spring:bind on a multi-select list Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring:bind on a multi-select list

    I have a wizard form controller and on one of the pages, it uses the following tags to select a single item off the list and bind it to one property.

    <spring:bind path="teacher.type.id" >
    <select name="<c:out value="${status.expression}" />" size="6">
    <c:forEach var="teacherType" items="${teacherTypes}">
    <option value="<c:out value="${teacherType.id}"/>" <c:if test='${status.value==teacherType.id}'>selected="s elected"</c:if> >
    <c:out value="${teacherType.type}"/>
    </option>
    </c:forEach>
    </select>
    </spring:bind>

    I need to modify this select to allow for multiple selection, what would be the bind type if there are multiple selection? Or is there are a way to bind?

    If not, are there other ways to handle this?

    Thanks.

  • #2
    I realized that there is a onBind() method that I can use. It does provide the HTTPServletRequest object, hence I can just do a getParameterValues() to retrieve the multi-selected items and manually bind the values to the command.

    I was surprised that the values do stick from one page to another, I guess spring probably stores this in a session, hence "binding" the object.

    If there are other better solutions than this, or if there are other things that I need to be aware of when using this approach, please let me know.

    Thanks.

    Comment


    • #3
      Found the following webpage ...

      http://www.jroller.com/page/raible?e...ith_spring_mvc

      which precisely describes what I'm looking for.

      Comment

      Working...
      X