JSF - Facelet

> Procedural Languages > Java > JavaServer Faces (JSF)

1 - About

The term Facelets refers to the view declaration language for JavaServer Faces technology.

Facelets is a page declaration language that is used to build JavaServer Faces views using HTML style templates and to build component trees.

Facelets can be use with JSF 1.1 and higher and is a part of JSF 2.0.

Facelets features include the following:

  • Use of XHTML for creating web pages
  • Support for Facelets tag libraries in addition to JavaServer Faces and JSTL tag libraries
  • Support for the Expression Language (EL)
  • Templating for components and pages

Facelets technology offers several advantages.

  • Code can be reused and extended for components through the templating and composite component features.
  • When you use the JavaServer Faces Annotations feature, you can automatically register the managed bean as a resource available for JavaServer Faces applications. In addition, implicit navigation rules allow developers to quickly configure page navigation. These features reduce the manual configuration process for applications.
  • Most important, JavaServer Faces technology provides a rich architecture for:
    • managing component state,
    • processing component data,
    • validating user input,
    • and handling events.
Advertising

3 - Example

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets
    </h:body>
</html>

4 - Documentation / Reference