views:

399

answers:

4

How I can bind a collection to a form for inputdata (not for show)

+1  A: 

e.g. for a Set<Jokers>

protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    binder.registerCustomEditor(
        Set.class,
        "[nameOfTheClassMemberItShouldGoto]",
        new CustomCollectionEditor(Set.class) {
            protected Object convertElement(Object element) {
                return (element == null ? null : getQueryService().getJoker(element.toString()));
            }
        }
    );
}

or similar to this

jitter
A: 

But I want to add elemento to the set using a form, I don't known how to do it

mathyas
A: 

looking for the same. Is there any solution ??

Amit
A: 

I did the same question and got a nice solution, take a look here http://stackoverflow.com/questions/3283920/how-to-bind-a-list-of-object-to-springmvc-controller

Guilherme Oenning