background image

Request Processing

<< The CustomerBean Component | The NavigationEnumBean Class >>
<< The CustomerBean Component | The NavigationEnumBean Class >>

Request Processing

The page fragment template/links.jsp generates the list of bank function links at the top of
every page. Notice that the customer is retrieved from the userPrincipal object, which is set
when the customer logs in (see
"Protecting the Web Client Resources" on page 1073
). After the
customer is set, the page can retrieve the collection of accounts from CustomerBean.
As shown by the following code from links.jsp, the ID of the first account in the collection of
accounts is set into request scope. The setPropertyActionListener tag is nested inside the
commandLink
tag, which represents the hyperlink that launches the atm.jsp page. This
setPropertyActionListener
tag causes the account ID to be set in request scope when the
hyperlink is clicked.
...
<c:set var=
"accountId" scope="request"
value=
"${customerBean.accounts[0].accountId}"/>
<h:commandLink value=
"#{bundle.ATM}" action="atm">
<f:setPropertyActionListener
target=
"#{requestScope.accountId}"
value=
"#{customerBean.accounts[0].accountId}"/>
</h:commandLink>
...
Request Processing
When a user clicks on a button or a hyperlink, the application navigates to a new page or reloads
the current page. Navigation to all pages listed in
Table 37­2
is configured in the
web/WEB-INF/faces-config.xml
file using a set of navigation rules.
As described in
"Configuring Navigation Rules" on page 451
, the JavaServer Faces navigation
mechanism matches a logical outcome String or an action method to one of the navigation
rules to determine which page to open next. The button or hyperlink that the user clicks
specifies the logical outcome String or action method with its action attribute.
Although it's not necessary to do so, the web client of Duke's Bank uses an Java SE Enum class to
encapsulate all the possible logical outcomes for the application:
public enum Navigation
{
main,
accountHist,
accountList,
atm,
atmAck,
transferFunds,
transferAck,
error,
logout;
Web Client
Chapter 37 · The Duke's Bank Application
1071