Results 1 to 3 of 3

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

  1. #1
    Join Date
    Nov 2011
    Posts
    4

    Question <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. #2
    Join Date
    Aug 2010
    Location
    Broomfield, CO
    Posts
    20

    Default

    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.

  3. #3
    Join Date
    Nov 2011
    Posts
    4

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •