Java Reference
In-Depth Information
By using the validation information instead of hard-coded values in the
JSP, we can change the minimum and maximum allowed number of
aliases in the action bean's validation and sleep well at night. The JSP
automatically uses the new values when generating the options in the
select box.
10.5
Creating a Wizard
After the user has filled in all fields and chosen to have one or more
After filling out the aliases, the user sees a page confirming that reg-
istration is complete. If the user chooses zero aliases, the registration
process goes straight to the confirmation page.
We want the registration form to alter its flow according to the user
input, and in the case of entering aliases, we want to create a form
where the number of text fields depends on what the user chose in the
previous page.
A form broken up into two or more pages is called a wizard. Wizards
are useful for forms that involve multiple steps, such as our registration
process, and can also be used just to break up a form that includes a
large number of fields. In the latter situation, you avoid intimidating the
user with a big daunting form that endlessly scrolls down the screen.
Splitting a form across a few pages makes it easier to digest.
wizard. Notice that with a wizard, the same action bean handles all the
pages of a wizard. Here,
RegisterActionBean
handles requests from both
register.jsp
and
aliases.jsp
, as well as the initial request from elsewhere in
the application to arrive at the registration process (labeled Start in the
diagram) and the redirect requests from the
register
( ) and
save
( ) event
handlers.
Let's take it one step at a time. First, linking to
RegisterActionBean
calls
its default event handler, which forwards to
register.jsp
:
private static final
String VIEW = "/WEB-INF/jsp/register.jsp";
@DefaultHandler
@DontValidate
public
Resolution view() {
return new
ForwardResolution(VIEW);
}
Search WWH ::
Custom Search