background image

Client Components

<< Design Strategies | The CustomerBean Component >>
<< Design Strategies | The CustomerBean Component >>

Client Components

In the Duke's Bank application, CustomerBean acts as a facade to the enterprise beans. Through
it, the backing beans can invoke methods on the enterprise beans. For example,
TransferFundsBean
can indirectly invoke the transferFunds method of the
TxControllerBean
enterprise bean by first calling getTxController on CustomerBean then
calling transferFunds on the TxController interface.
The other backing beans have much richer functionality. ATMBean sets acknowledgment strings
according to customer input, and AccountHistoryBean massages the data returned from the
enterprise beans in order to present the view of the data required by the customer.
The web client uses a template mechanism implemented by custom tags (discussed in
"A
Template Tag Library" on page 267
) to maintain a common look across all the JSP pages. The
template mechanism consists of three components:
template.jsp
determines the structure of each screen. It uses the insert tag to compose a
screen from subcomponents.
screendefinitions.jspf
defines the subcomponents used by each screen. All screens have
the same banner, but different title and body content (specified in the JSP Pages column in
Table 37­2
).
Finally, the web client uses logic tags from the JSTL core tag library to perform flow control and
tags from the JSTL fmt tag library to localize messages and format currency.
Client Components
All the JavaBeans components used in the web client are instantiated by the managed bean
facility (see
"Configuring a Bean" on page 311
) when they are encountered in the page, such as
when an EL expression references the component. The managed bean facility is configured in
the faces-config.xml file. The following managed-bean elements from the faces-config.xml
file specify how AccountHistoryBean and CustomerBean are to be instantiated and stored in
scope:
<managed-bean>
<managed-bean-name>accountHistoryBean</managed-bean-name>
<managed-bean-class>
com.sun.tutorial.javaee.dukesbank.web.AccountHistoryBean
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
...
<managed-property>
<property-name>accountId</property-name>
<value>#{param.accountId}</value>
</managed-property>
<managed-property>
...
Web Client
Chapter 37 · The Duke's Bank Application
1069