10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In the Duke’s Bank application, CustomerBean acts as a facade to the enterprise beans. Through<br />

it, the backing beans can invoke methods on the enterprise beans. For example,<br />

TransferFundsBean can indirectly invoke the transferFunds method of the<br />

TxControllerBean enterprise bean by first calling getTxController on CustomerBean then<br />

calling transferFunds on the TxController interface.<br />

<strong>The</strong> other backing beans have much richer functionality. ATMBean sets acknowledgment strings<br />

according to customer input, and AccountHistoryBean massages the data returned from the<br />

enterprise beans in order to present the view of the data required by the customer.<br />

<strong>The</strong> web client uses a template mechanism implemented by custom tags (discussed in “A<br />

Template Tag Library” on page 264) to maintain a common look across all the JSP pages. <strong>The</strong><br />

template mechanism consists of three components:<br />

■ template.jsp determines the structure of each screen. It uses the insert tag to compose a<br />

screen from subcomponents.<br />

■ screendefinitions.jspf defines the subcomponents used by each screen. All screens have<br />

the same banner, but different title and body content (specified in the JSP Pages column in<br />

Table 37–2).<br />

Finally, the web client uses logic tags from the JSTL core tag library to perform flow control and<br />

tags from the JSTL fmt tag library to localize messages and format currency.<br />

Client Components<br />

All the <strong>Java</strong>Beans components used in the web client are instantiated by the managed bean<br />

facility (see “Configuring a Bean” on page 309) when they are encountered in the page, such as<br />

when an EL expression references the component. <strong>The</strong> managed bean facility is configured in<br />

the faces-config.xml file. <strong>The</strong> following managed-bean elements from the faces-config.xml<br />

file specify how AccountHistoryBean and CustomerBean are to be instantiated and stored in<br />

scope:<br />

<br />

accountHistoryBean<br />

<br />

com.sun.tutorial.javaee.dukesbank.web.AccountHistoryBean<br />

<br />

request<br />

...<br />

<br />

accountId<br />

#{param.accountId}<br />

<br />

<br />

...<br />

Web Client<br />

Chapter 37 • <strong>The</strong> Duke’s Bank Application 1061

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!