Expert Spring MVC and Web Flow

(Dana P.) #1

Listing 6-72.Wizard Command Class


public class CreateAccount {


private Account account = new Account();
private String confirmPassword;

public Account getAccount() {
return account;
}
public void setAccount(Account account) {
this.account = account;
}
public String getConfirmPassword() {
return confirmPassword;
}
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}

}


You might remember all those tags we used in the JSP files. You can
see here why we need to use them, as the Accountclass is nested inside the command bean
(instead of being the command bean itself ). And the Addressobject is inside the Account,
requiring another tag.


■Tip The is not required if you have nested objects in your command bean, but it
comes in handy when you begin to modularize your JSP pages.


Controller


It is time to look at the concrete implementation of the wizard itself, which surprisingly isn’t
that complicated. The AbstractWizardFormControllerdoes a good job at performing the work
of page flows and validation. All that we have left to do is to fill out the validation logic and
save the Accountinstance at the end of the wizard. Listing 6-73 contains the Controllerimple-
mentation.


Listing 6-73.Wizard Controller


public class CreateAccountWizardController extends AbstractWizardFormController {


private AccountService accountService;

public CreateAccountWizardController() {
setCommandName("createAccount");

CHAPTER 6 ■THE CONTROLLER MENAGERIE 191
Free download pdf