
Actions and Navigation
Another JSF expression is evaluated when the server receives the request. The #{user.authenticate}
expression represents a JSF method binding expression (versus #{user.name} which is a value binding
expression). Method binding expressions are found in the action attribute of things like command/submit
buttons. Notice the authenticate method in the LoginBean class. When evaluated, the authenticate method,
called an action method, is invoked by the JSF framework.
The authenticate method from the LoginBean.
public String authenticate() {
if (getName().startsWith("Jim")) {
setError("Sorry, no Jims are allowed");
return null;
} else {
setError(null);
return "authenticated";
}
}
After request values are applied to the model (in this case the LoginBean), the JSF framework calls on the
action method. More precisely, it is the navigation handler in the JSF framework that calls on the action
method. Action methods cannot take parameters and they return either a String (called an action outcome) or
null. The action outcome string suggests a navigational rule for the navigation handler to follow. Navigation
rules define what JSP (view) the JSF framework should display next.
Where are the navigational rules and how do action outcomes map to them?
All the unconnected dots of this application, including navigational rules, are defined in the Faces
configuration file.
Actions and Navigation
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any copying is strictly prohibited.
Courseware
Training Resources
Tutorials
Services