The Java EE 6 Tutorial, Volume I

Creating the Web Page

In a typical Facelets application, web pages are created in XHTML. The example web page, beanhello.xhtml, is a simple XHTML page. It contains the following content:

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
       <title>JavaServer Faces Hello World Application</title>
    </head>
    <body> 
    		#{hello.world}
    </body>
</html>

A Facelets XHTML web page can also contain several other elements which are covered later in this tutorial.

The web page connects to the backing bean through the Unified Expression Language (EL) value expression #{hello.world}, which retrieves the value of the world property from the backing bean Hello. Note the use of hello to reference the backing bean Hello. If no name is specified in the @ManagedBean annotation, the backing bean is always accessed with the first letter of the class name in lowercase.

For more information on using EL expressions, see Chapter 6, Unified Expression Language. For more information about Facelets technology, see Introduction to Facelets. For more information about JavaServer Faces programming model and building web pages using JavaServer Faces technology, see Chapter 7, Using JavaServerTM Faces Technology in Web Pages.