0

Here is my simple test class (command object class)

public class Test {
private List<MyEnum> list;

//setters and getters
}

and here is the part od JSP page:

<form:form ......>
<form:select multiple="true" path="list" items="enumvalues">
</form:form>

I would like to bind all selected items from jsp list to my command object list. What is the best way to do this? I know, that I need to write some custom editors but after some tests I have no idea how to achieve that.

I would be grateful for any help.

PiratDrogowy
  • 5
  • 1
  • 4

1 Answers1

1

If you have proper access to list in JSP, this should work:

<form:form ...>
  <form:select multiple="true" path="list">
    <form:options />
  </form:select>
</form:form>

P.S. If you want options have different readable name than value, just override enum value's toString() and Spring MVC will magically use it as description.

Grzegorz Rożniecki
  • 27,415
  • 11
  • 90
  • 112
  • Thanks a lot! `` did the work instead of `items` option inside `` tag. – PiratDrogowy Aug 31 '12 at 07:28
  • @PiratDrogowy can you provide a solution to this for me http://stackoverflow.com/questions/15730760/springmvc-how-to-bind-a-multi-select-option-element – devdar Apr 01 '13 at 03:58