Java Reference
In-Depth Information
Figure 3-11.
Form submission workflow in
SimpleFormController
To handle form submission, the controller needs to override one of the many tem-
plate methods. Since the goal is to just invoke a business service in the controller, you
can override the simplest method called
doSubmitAction
. With this method, you do not
need to explicitly return any
ModelAndView
object. The form bean is automatically set in
the model object by the framework itself, with the identifier as the command name. If
more data has to be passed, then the
onSubmit
method needs to be overridden. This
method allows the creation of a
ModelAndView
object, which can be used to pass more
data than with the default approach.
Listing 3-27 shows the modified controller.
Listing 3-27.
SaveNewPolicyController.java
public class SaveNewPolicyController extends SimpleFormController {
private UnderWritingBusinessDelegate uwrBusinessDelegate;
public SaveNewPolicyController() {
setCommandClass(PolicyFormBean.class);
}
