|
|
setSessionForm(true) calls formBackingObject
Hi,
I am a newbie trying to implement spring MVC in our web app. I have a SimpleFormController where i have setSessionForm(true). But still, on form submissions, the formBackingObject() method is being called everytime before onSubmit. another strange behavior is that after formBackingObject(), onSubmit() is being called twice for a single submission request which is causing db issues as the first submission already inserts a record in the db, the second one throws duplicate rows exception.
I understand that formBackingObject() call is required on form load but on form submissions, i want to bypass this method call (as i want to avoid db trips).
Any hints on the following 2 issues would be appreciated.
1. Why is formBackingObject() called on form submission even though setSessionForm(true).
2. Any clue on why the form is being submitted twice?
Thanks in advance,
asan
It works the other way around.
When showForm is called the formBackingObjet mehtod IS NOT CALLED.
This is because you want to show the form data which is stored in the session.
But onSubmit you want to store the new information to your command. This is why it gets called.
Do you have to overwrite this method? Sometimes it is enough to use the commandClass property.
EDIT: Could you post the important extracts of your controller? Including the formBackingObject and all quot;returnsquot; of ModelAndView!?
Originally Posted by LoreBut onSubmit you want to store the new information to your command. This is why it gets called.
No it doesn't that only happens when you have setSessionForm to false else it will use the object in the session.
There is probably something wrong in his mapping or his detection if something is a submit or a first rendering.
Originally Posted by mdeinumNo it doesn't that only happens when you have setSessionForm to false else it will use the object in the session.
There is probably something wrong in his mapping or his detection if something is a submit or a first rendering.
Yeah, you are right. I checked it.
Maybe he just has to set quot;method=postquot; ?
Originally Posted by LoriMaybe he just has to set quot;method=postquot; ?
Another reason might be an invalid submit caused by a binding error.
Joerg |
|