JSF 2.3 View Declaration Language: Facelets Variant.

Tag Libraries
Faces Core
The core JavaServer Faces custom actions that are independent of any particular RenderKit.
Pass Through Attributes

Facelet tag attributes in this namespace must be added to the pass through attribute map
on the UIComponent corresponding to the facelet tag. There are no tags in this tag library.

Usage example

<h:outputText value="Namespaced Attributes" p:foo="bar" />

Would cause <span foo="bar">Namespaced Attributes</span> to be rendered.

Pass Through Elements

The presence of an
attribute from this namespace on an otherwise non-JSF aware
markup element indicates that the markup element must be treated
as a JSF component that will be rendered equivalently to what is
specified directly in the Facelet page, with the added benefit
of being associated with a server side UIComponent
instance.

Please see the documentation for Java class javax.faces.view.facelets.TagDecorator.

h
This tag library contains JavaServer Faces component tags for all UIComponent + HTML RenderKit Renderer combinations defined in the JavaServer Faces Specification.
JSTL core

JSTL 1.2 core library

The pre JSF 2.0 version of Facelets incorrectly declared the taglib uri to be http://java.sun.com/jstl/core. For backwards compatibility implementations must correctly handle inclusions with the incorrect uri, and the correct uri, declared here.

JSTL functions
JSTL 1.1 functions library
Facelets Templating
 

The tags in this library add templating—a powerful view composition technique—to JSF. Templating is so useful that there are entire frameworks, such as Tiles and SiteMesh, that are built around the concept of templating. So what is templating, how can you benefit from it, and how does this tag library implement it?

If you've used JSP before, you've probably used jsp:include. The prototypical example for jsp:include is a header on each page in a web application. One JSP page, say header.jsp, encapsulates the header content, and the header is included by each page. You encapsulate and reuse content, so that changes to one file, header.jsp, affect the header on every page.

This tab library contains a tag—ui:include— that's analagous to jsp:include, but encapsulating and reusing content is only half the templating story, because templating also lets you encapsulate and reuse layout. You define a single template (meaning layout), and you reuse that template with multiple compositions. So now you can control the layout of many pages with a single template (layout). Let's take a look at an example.

A Templating Example

First, we define a template:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml"
  5.             xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  6.     <head>
  7.       <link href="styles.css" rel="stylesheet" type="text/css"/>
  8.       <title><ui:insert name="title">Default Title</ui:insert></title>
  9.     </head>
  10.  
  11.     <body>
  12.       <ui:debug/>
  13.       <div class="heading">
  14.         <ui:insert name="heading"/>
  15.       </div>
  16.  
  17.       <div class="content">
  18.         <ui:insert name="content"/>
  19.       </div>
  20.     </body>
  21. </html>

In the preceeding listing, we've defined a layout, also known as a template. That template uses the ui:insert tag to insert pieces of a page —namely, title, heading, and content— defined in a composition. Notice that on line 8, we define a default title, in case one isn't provided by the composition. Also note that on line 12 we have the ui:debug tag, which lets the user activate a popup window with debugging information by typing CTRL + Shift + d.

The title, heading, and content pieces of the page referenced in the template are defined in a separate XHTML file in a composition, like this:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml"
  5.    xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
  6.  
  7.   <body>
  8.     <ui:composition template="/layout.xhtml">
  9.  
  10.       <ui:define name="title">A List of Contacts</ui:define>
  11.       <ui:define name="heading">Contacts</ui:define>
  12.  
  13.       <ui:define name="content">
  14.         <ui:include src="contactsTable.xhtml" />
  15.       </ui:define>
  16.          
  17.     </ui:composition>
  18.   </body>
  19. </html>

At runtime, JSF synthesizes the two previous XHTML pages to create a single JSF view by inserting the pieces defined in the composition into the template (that template is layout.xhtml, which is the first listing above). JSF also disregards everything outside of the composition tag so that we don't wind up with two body elements in the view. Also, note that we use the ui:include tag on line 14 to include content (which happens to be a table) from another XHTML page, so that we can reuse that table in other views.

So why do we have two XHTML pages to define a single view? Why not simply take the pieces and manually insert them into the layout so that we have only a single XHTML page? The answer is simple: we have separated layout from the content so that we can reuse that layout among multiple compositions. For example, now we can define another composition that uses the same layout:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml"
  5.       xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
  6.  
  7.   <body>
  8.     <ui:composition template="/layout.xhtml">
  9.  
  10.       <ui:define name="title">Create a Contact</ui:define>
  11.       <ui:define name="heading">Create Contact</ui:define>
  12.  
  13.       <ui:define name="content">
  14.         <ui:include src="createContactForm.xhtml"/>
  15.       </ui:define>
  16.  
  17.     </ui:composition>
  18.   </body>
  19. </html>

By encapsulating the layout, we can reuse that layout among multiple compositions. Just like ui:include lets us encapsulate and reuse conent, JSF compositions let us encapsulate and reuse layout, so that changes to a single layout can affect multiple views. Fundamentally, that's what this tag library is all about.




Output Generated by Tag Library Documentation Generator.