Announcement Announcement Module
Collapse
No announcement yet.
<mvc:annotation-driven/> and binding to collections Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <mvc:annotation-driven/> and binding to collections

    Since including <mvc:annotation-driven/> I have experienced a problem when binding the selections of multi-select list box to its corresponding list property on the command bean. Before introducing <mvc:annotation-driven/> it worked correctly.

    I have a custom collection editor:

    Code:
    @InitBinder
    public void initBinder(WebDataBinder binder) {
       binder.registerCustomEditor(List.class, new CustomCollectionEditor(List.class) {
          protected Object convertElement(Object element) {			
             String fieldName = (String)element;
    
             for (Field field : fields) {
                if (field.getFieldName().equals(fieldName))
                   return field;
             }
    				
             return element;
          }
       });
    }
    which previously would result in the form controller receiving a List<Field> representing the list selections. However, since using the <mvc:annotation-driven/> what I now get is a List<List<Field>>.

    Can anyone help shed light on this behaviour?

  • #2
    It sounds like the List<...> is implicit, meaning you get it for free - which would make sense considering you're talking about a select box.

    Comment


    • #3
      Answer is here:

      http://stackoverflow.com/questions/8...to-collections

      Comment

      Working...
      X