Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of formBackedObject

 
Parthiban Malayandi
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi daniel,

Welcome to the Ranch, thanks for taking the time to register and answer this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic