*
The moose likes Spring and the fly likes Use of formBackedObject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Use of formBackedObject" Watch "Use of formBackedObject" New topic
Author

Use of formBackedObject

Parthiban Malayandi
Ranch Hand

Joined: Apr 15, 2008
Posts: 70
Hi all,

I have just started to learn Spring MVC and learned about formBackingObject method.

I have wrote a simple program to understand the concept .

MyCustomFormController



Person Class



I came to know that formBackingObject is called twice ( first time when form is loaded with GET request and when it is submitted with POST method) but every time I'm getting null values
when I print the Person object where as I'm getting values in onSubmit method.

Can you please explain what is the significance of formBackingObject method ?

Thanks in advance
daniel webber
Greenhorn

Joined: Aug 16, 2013
Posts: 1
I know this is a really old post but since it was not answered and it comes up in searches I figured I would answer it.

You have to make you backing object a session object by adding this to your constructor:
setSessionForm(true);

your backing object now has to be serializeable for the code to run but it will not get a second call to the getFormBackingObject when it is submitted.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Hi daniel,

Welcome to the Ranch, thanks for taking the time to register and answer this.


[How To Ask Questions][Read before you PM me]
 
 
subject: Use of formBackedObject