I'm using SpringMVC 3.0.3.
I store form object to session using @SessionAttribute annotation. I've created my CustomCollectionEditor to turn on alwaysCreateNewCollection, but it doesn't work correctly.
I have one form that has one List<String> like following:
Then I registered my CustomCollectionEditor to my controller:Code:public class FooForm { private List<String> bar; (omit getter/setter) }
I send post two request.Code:@Controller public class SomeController { @InitBinder protected void initBinder(WebDataBinder binder) { binder.registerCustomEditor(List.class, new MyCustomCollectionEditor); } (omit) }
1st request:
bar[0]=a1
bar[1]=b1
bar[2]=c1
Then FooForm has correct List<String> field(bar[0]=a1, bar[1]=b1, bar[2]=c1).
2nd request:
bar[0]=a2
bar[1]=b2
Then FooForm's bar field has bar[0]=a2, bar[1]=b2, bar[2]=c1.
I want to eliminate bar[2]=c1, so I've create my CustomCollectionEditor.
However BeanWrapperImpl doen't call my CustomCollectionEditor on second request because BeanWrapperImpl can find form object from session. I have no way to change this binding behavior.
I couldn't find any good way other than create custom SesstionAttributeStore to avoid this problem. But I think it is not good way to solve this. Is this bug? Or is there any good way to solve this problem?


Reply With Quote