Expert Spring MVC and Web Flow

(Dana P.) #1
Table 6-2.SimpleFormController Properties
Property Name Default Description Found In
formView null The name of the view that SimpleFormController
contains the form.
successView null The name of the view to SimpleFormController
display on successful
completion of form
submission.
bindOnNewForm false Should parameters be AbstractFormController
bound to the form bean
on initial views of the form?
(Parameters will still be
bound on form submission.)
sessionForm false Should the form bean be AbstractFormController
stored in the session
between form view and
form submission?
commandName "command" Logical name for the BaseCommandController
form bean.
commandClass null The class of the form bean. BaseCommandController
validator(s) null One or more Validators BaseCommandController
that can handle objects of
type configured by
commandClassproperty.
validateOnBinding true Should the Controller BaseCommandController
validate the form bean
after binding during a
form submission?

This class’s work flow can be split into two parts: viewing the form and handling the
submission of the form. This controller provides both actions from a single URL, or HTTP
resource. In other words, you will use the URL /app/editPerson.htmlto view the form and
to submit the form. Semantically, using the same resource (URL) for both viewing (via HTTP
GET) and submitting (via HTTP POST) maps very well to HTTP’s modeling of a resource and
how best to interact with the resource.

■Tip The HTTP specification specifies eight verbs, or commands, for accessing resources on the web.
The two most popular verbs are GET and POST. GET is used when fetching, or reading, the resource, and the
results are intended to be cacheable and repeatable without repercussions on the resource (i.e., GET is an
idempotent action). In contrast, POST is meant for altering or modifying the resource, which is why it is used
most often for form submissions. A POST action is not meant to be repeated without explicit approval from
the user.

150 CHAPTER 6 ■THE CONTROLLER MENAGERIE

Free download pdf