Java Reference
In-Depth Information
Joe Asks. . .
What About Going Back to the Previous Page?
If we want to allow the user to go back to the previous page in a
wizard, we have to take into account that the default behavior
is to perform validation on the data that the user entered in the
current page before invoking the event handler that sends the
user to the previous page. If the user entered invalid data or did
not fill in required fields, validation errors will occur.
To let the user go back without forcing them to enter valid data
in the current page, we have to “manually” adjust the valida-
tions with the on= attribute of @Validate or with @DontValidate on
the event handler.
Of course, if the user goes back to the previous page using
the browser's Back button, any values that they entered on the
current page will be lost. Hitting Back does not send any data
to the server, so there's not much we can do about that!
10.6
The Login Page
After registering, the user is ready to log in at the page shown in Fig-
ure 10.7 , on the following page.
After tackling that registration wizard, this page seems so simple that
you could implement it with your eyes closed. In fact, the only part
that's worth a look is the validation of the username and password:
Download email_19/src/stripesbook/action/LoginActionBean.java
@ValidationMethod
public void validateUser(ValidationErrors errors) {
User user = userDao.findByUsername(username);
if (user == null ) {
errors.add("username",
new SimpleError("The primary email was not found."));
}
else if (!user.getPassword().equals(password)) {
errors.add("password",
new SimpleError("The password is incorrect."));
}
}
private UserDao userDao = MockUserDao.getInstance();
 
 
 
Search WWH ::




Custom Search