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.

A Simple <strong>Java</strong>Server Faces Application<br />

288<br />

<strong>The</strong> mapping to FacesServlet shown above uses a prefix mapping to identify a JSP page as<br />

having <strong>Java</strong>Server Faces components. Because of this, the URL to the first JSP page of the<br />

application must include the mapping. To accomplish this, the guessNumber example includes<br />

an HTML page that has the URL to the first JSP page:<br />

<br />

See “Identifying the Servlet for Life Cycle Processing” on page 456 for more information on how<br />

to map the FacesServlet instance.<br />

Creating the Pages<br />

Creating the pages is the page author’s responsibility. This task involves laying out UI<br />

components on the pages, mapping the components to beans, and adding tags that register<br />

converters, validators, or listeners onto the components.<br />

In this section you will build the<br />

tut-install/javaeetutorial5/examples/examples/web/guessNumber/web/greeting.jsp<br />

page, the first page of the guessNumber application. As with any JSP page, you’ll need to add the<br />

usual HTML and HEAD tags to the page:<br />

<br />

Hello <br />

...<br />

<br />

You’ll also need a page directive that specifies the content type:<br />

<br />

Declaring theTag Libraries<br />

In order to use <strong>Java</strong>Server Faces components in JSP pages, you need to give your pages access to<br />

the two standard tag libraries, the HTML component tag library and the core tag library using<br />

taglib declarations:<br />

<br />

<br />

<strong>The</strong> first taglib declaration declares the HTML component tag library with a prefix, h.All<br />

component tags in the page have this prefix. <strong>The</strong> core tag library is declared with the prefix f.All<br />

core tags in the page have this prefix.<br />

“User Interface Component Model” on page 297 includes a table that lists all the component<br />

tags included with <strong>Java</strong>Server Faces technology. “Adding UI Components to a Page Using the<br />

HTML Component Tags” on page 325 discusses the tags in more detail.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

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

Saved successfully!

Ooh no, something went wrong!