Document Information

Preface

Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

Part II The Web Tier

3.  Getting Started with Web Applications

4.  Java Servlet Technology

5.  JavaServer Faces Technology

6.  Introduction to Facelets

What's Facelets?

Developing a Simple JavaServer Faces Application

Creating a Facelets application

Developing a Backing Bean

Creating Facelets Views

Creating a Resource Bundle

Configuring the Application

Adding Managed Bean Declarations

Adding Resource Bundle Declarations

Adding Page Navigation Rules

Web Application Deployment Descriptor

Building, Packaging, Deploying and Running the Application

To Create the Example Facelets Application Project

To Create the Sample Application

7.  Using JavaServer Faces Technology in Web Pages

8.  Developing with JavaServer Faces Technology

9.  Configuring JavaServer Faces Applications

Part III Web Services

10.  Introduction to Web Services

11.  Building Web Services with JAX-WS

12.  Building RESTful Web Services with JAX-RS and Jersey

Part IV Enterprise Beans

13.  Enterprise Beans

14.  Getting Started with Enterprise Beans

15.  Running the Enterprise Bean Examples

Part V Persistence

16.  Introduction to the Java Persistence API

17.  Running the Persistence Examples

18.  The Java Persistence Query Language

Part VI Security

19.  Introduction to Security in the Java EE Platform

20.  Using Java EE Security

21.  Securing Java EE Applications

22.  Securing Web Applications

Part VII Java EE Supporting Technologies

23.  Introduction to Java EE Supporting Technologies

24.  Transactions

25.  Resource Connections

Index

 

Advantages of Facelets

JavaServer Faces technology was created with the intention of working with JavaServer Pages (hereafter referred to as JSP) applications, to provide a clean separation of the presentation and behavior of web applications.

Prior to Facelets, the most commonly used presentation technology for JavaServer Faces applications was JavaServer Pages (JSP). However using JavaServer Faces technology in JSP presents its own difficulties and limitations.

In JSP, elements and components in a web page are processed and rendered in a progressive order. However, JavaServer Faces also provides its own processing and rendering order. This can cause unpredictable behavior when web applications are executed. Facelets provides a better programming and rendering model for JavaServer Faces technology and resolves the issues faced in using JavaServer Faces with JSP.

Templating, reuse of code, and ease of development are important considerations for developers to adopt JavaServer Faces as the platform for large scale projects. By supporting these features, Facelets reduces the UI development and deployment time.

Other advantages include the following:

  • Faster compilation time

  • Compile time validation

  • High performance rendering

  • Functional extensibility of components and other server-side objects through customization

  • Support for code reuse through templating and composite components

For more information on templating, see Templating. For more information on composite components, see Composite Components.

Authoring Facelets Pages

Facelets views are usually written using XHTML markup language. This allows Facelets pages to be more portable across diverse development platforms. JavaServer Faces implementations should support all XHTML pages created in conformance with the XHTML Transitional DTD, as listed at http://www.w3.org/TR/xhtml1/#a_dtd_XHTML-1.0-Transitional.

By convention, JavaServer Faces web pages that are authored using Facelets technology have .xhtml extension.

Tag Libraries and EL Support

This section covers the following topics:

Tag Library Support

JavaServer Faces technology uses various tags to express UI components in a web page. Facelets uses the XML namespace declarations to support the JavaServer Faces tag library mechanism. However, for Facelets, the role of tag libraries is not as important as in JSP.

Table Table 6-1 shows the tag libraries supported by Facelets.

Table 6-1 Tag Libraries Supported by Facelets

Tag Library

URI

prefix

Example

Contents

JSF UI Tag Library

http://java.sun.com/jsf/facelets

ui:

ui:component

ui:insert

Tags for for templating

JSF HTML Tag Library

http://java.sun.com/jsf/html

h:

h:head

h:body

h:outputText

h:inputText

JavaServer Faces component tags for all UIComponent + HTML RenderKit Renderer combinations defined in the JavaServer Faces 2.0 Specification.

JSF Core Tag Library

http://java.sun.com/jsf/core

f:

f:actionListener

f:attribute

Tags for JavaServer Faces custom actions that are independent of any particular RenderKit.

JSTL Core Tag Library

http://java.sun.com/jsp/jstl/core

fn:

fn:toUpperCase

fn:toLowerCase

JSTL 1.1 Core Tag Library

JSTL Functions Library

http://java.sun.com/jsp/jstl/functions

c:

c:forEach

c:catch

JSTL 1.1 Functions Tag Library

In addition, Facelets also supports composite components for which you can declare custom prefixes. For more information on composite components, see Composite Components.

Unified EL Support

Based on the JavaServer Faces support for unified expression language (EL) syntax defined by JSP 2.1, Facelets supports EL. EL expressions are used to bind UI component objects or values, or managed-bean methods or managed-bean properties. For more information on using EL expressions, see Using the Unified EL to Reference Backing Beans.