This controller has a complex work flow, and we will break it down into its core compo-
nents. Then, we will show you the best extension points for altering the work flow in the
controller. We begin by illustrating all possible paths through the controller.
Figure 6-1 illustrates the many paths through the work flow of handling forms with
SimpleFormController.
Figure 6-1.SimpleFormController activity diagram
We will focus on the initial retrieval of the HTML form first. The controller uses the
method isFormSubmission()to determine if the HTTP request is either a form viewing or
form submission. The default implementation of this method merely checks the HTTP
method, and if it is a POST then isFormSubmission()returns true. The controller does not
consider a HTTP GET request a form submission. However, this method is not final, so your
implementation is free to define whatever criteria is appropriate to indicate the request
should be treated as a submission. If indeed the request is not a form submission, the
Resource requested
Retrieve form object from session
Everything from AbstractController
Is a form submission?Yes Is a session form? YesIs form bean in session?Yes
Create form object
Create and init binder
No
Create NewForm object
Create and init binder
No No
Remove from session
Bind request parameters to form object
Bind to form object
Store form in session
Should bind on NewForm?
Yes
No
Validate form object
Yes
onBindAndValidate
Validate on bind? Suppress validation?
Yes No
No
Yes
Collect reference data
No
Is a session form?
Display form view
No Handle form submit
Errors from binding or validation?
Yes
Done
CHAPTER 6 ■THE CONTROLLER MENAGERIE 151