background image

Creating the Pages

<< Mapping the FacesServlet Instance | Adding the view and form Tags >>
<< Mapping the FacesServlet Instance | Adding the view and form Tags >>

Creating the Pages

application must include the mapping. To accomplish this, the guessNumber example includes
an HTML page that has the URL to the first JSP page:
<a href=
"guess/greeting.jsp">
See
"Identifying the Servlet for Life Cycle Processing" on page 459
for more information on how
to map the FacesServlet instance.
Creating the Pages
Creating the pages is the page author's responsibility. This task involves laying out UI
components on the pages, mapping the components to beans, and adding tags that register
converters, validators, or listeners onto the components.
In this section you will build the
tut-install/javaeetutorial5/examples/examples/web/guessNumber/web/greeting.jsp
page, the first page of the guessNumber application. As with any JSP page, you'll need to add the
usual HTML and HEAD tags to the page:
<HTML xmlns=
"http://www.w3.org/1999/xhtml"xml:lang="en">
<HEAD> <title>Hello</title> </HEAD>
...
</HTML>
You'll also need a page directive that specifies the content type:
<%@ page contentType=
"application/xhtml+xml" %>
Declaring the Tag Libraries
In order to use JavaServer Faces components in JSP pages, you need to give your pages access to
the two standard tag libraries, the HTML component tag library and the core tag library using
taglib
declarations:
<%@ taglib uri=
"http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri=
"http:.//java.sun.com/jsf/core" prefix="f" %>
The first taglib declaration declares the HTML component tag library with a prefix, h. All
component tags in the page have this prefix. The core tag library is declared with the prefix f. All
core tags in the page have this prefix.
"User Interface Component Model" on page 299
includes a table that lists all the component
tags included with JavaServer Faces technology.
"Adding UI Components to a Page Using the
HTML Component Tags" on page 327
discusses the tags in more detail.
A Simple JavaServer Faces Application
The Java EE 5 Tutorial · September 2007
290