Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Use of formBackedObject

 
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
 
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.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • 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.
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic