Announcement Announcement Module
No announcement yet.
spring:bind on a multi-select list Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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="" >
    <select name="<c:out value="${status.expression}" />" size="6">
    <c:forEach var="teacherType" items="${teacherTypes}">
    <option value="<c:out value="${}"/>" <c:if test='${}'>selected="s elected"</c:if> >
    <c:out value="${teacherType.type}"/>

    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?


  • #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.



    • #3
      Found the following webpage ...

      which precisely describes what I'm looking for.