I am new to Spring Framework and trying to understand the functionality of formBackingObject and comparing it with referenceData methods, both these objects confuse me when am trying to relate them to HTTP Request Cycle from a Spring MVC point of view.
I would really appreciate if someone can explain these two objects with reference to an example.
Q: What is the difference between formbacking object and reference Data Object ?
When you load a web page, you will want to pass data to it so that it can render.
Some of this data will be purely informational, read-only; data that the page needs in order to render, but that isn’t part of the current transaction. Examples: a list of countries to populate a drop-down, a list of possible products the user can buy.
Other data will be used for reading and writing: the contents of a form, say, must be populated with the current data, but can also be updated by the user. This set of data will be bound to the form; data sent to the page will render, data sent from the page (by the user) will cause an update. Examples: the user’s name and address; the current order.
All of this data will typically be stored in one or more objects that the page needs access to.
Objects containing informational data should be placed in the map provided by the
referenceData()method. There can be as many such objects as you like.The data to be bound to the form, the read/write data, must be contained in a single object. This object should be returned by the
formBackingObject()method.I’ll add that in more recent versions of Spring, annotations are used instead of these “built-in” methods.