Javatpoint Logo
Javatpoint Logo

Creating Facelets Views and Mapping Faces Servlet

Facelets views are XHTML pages. You can create a web page or view, by adding components to the page, wire the components to backing bean values and properties, and register converters, validators, or listeners on the components.

The XHTML web pages serve as the front end. The first page of your application is index.xhtml by default.

The first section of the web page declares the content type for the page, which is XHTML:

The next section specifies the language of the XHTML page and then declares the XML namespace for the tag libraries that are used in the web page.

// index.xhtml

The Facelets HTML tag begin with h: are used to add components on the web page and core tag f:validateRequired is used to validate user input.

An h:inputText tag accepts user input and sets the value of the managed bean property name through the EL expression #{}.

After running index.xhtml file, a HTML index page is rendered by JSF. The output is given below.

// Output: index page

JSF Facelets view and mapping 1

This is the process to create Facelets view. Now, you can create second xhtml page as response.xhtml as giving the below.

// response.xhtml

After running the index file, following output will be displayed.


// index page

JSF Facelets view and mapping 2

// response page

JSF Facelets view and mapping 3

Mapping The Faces Servlet

Configure of a JavaServer Faces application is done by mapping the Faces Servlet in the web deployment descriptor file a web.xml.

In NetBeans IDE, a web deployment descriptor file is automatically created for you. A autogenerated web.xml file is given below.

// web.xml

Next TopicFacelets Templates

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA