Expert Spring MVC and Web Flow

(Dana P.) #1

Figure 6-2.Order in which callback methods are called


■Tip Choose the best form submit callback to implement based on which objects you need and whether
the default success view is always appropriate. Implement only one callback method.


SimpleFormController Examples


It is time to see the SimpleFormControllerin action. To begin, we will create a form for a sim-
ple person. This example brings together what we have covered from the DataBinderand the
work flow of the SimpleFormController.
The Personclass used in this example (shown in Listing 6-39) has three properties: a Name,
when he was born, and his favorite programming language. To make things more interesting,
the nameproperty is an example of a nested Nameobject (shown in Listing 6-40), and the bornOn
property will require a custom PropertyEditor.


Listing 6-39.Person Bean


public class Person {


private Name name = new Name();
private Date bornOn;
private String favoriteProgrammingLanguage;

public Date getBornOn() {
return bornOn;
}
public void setBornOn(Date bornOn) {
this.bornOn = bornOn;
}

onSubmit(request, response, formBean, errors)

onSubmit(formBean, errors)

onSubmit(formBean)

doSubmitAction(formBean)

CHAPTER 6 ■THE CONTROLLER MENAGERIE 155
Free download pdf