The Java EE 6 Tutorial

Using Core Tags

The tags included in the JavaServer Faces core tag library are used to perform core actions that are not performed by HTML tags. Commonly used core tags, along with the functions they perform, are listed in Table 7–8.

Table 7–8 The Core Tags

Tag Categories 

Tags 

Functions 

Event handling 

f:actionListener

Adds an action listener to a parent component 

f:phaseListener

Adds a PhaseListener to a page

f:setPropertyActionListener

Registers a special action listener whose sole purpose is to push a value into a backing bean when a form is submitted 

f:valueChangeListener

Adds a value-change listener to a parent component 

Attribute configuration 

f:attribute

Adds configurable attributes to a parent component 

Data conversion

f:converter

Adds an arbitrary converter to the parent component 

f:convertDateTime

Adds a DateTimeConverter instance to the parent component

f:convertNumber

Adds a NumberConverter instance to the parent component

Facet 

f:facet

Adds a nested component that has a special relationship to its enclosing tag 

f:metadata

Registers a facet on a parent component

Localization 

f:loadBundle

Specifies a ResourceBundle that is exposed as a Map

Parameter substitution

f:param

Substitutes parameters into a MessageFormat instance and adds query string name-value pairs to a URL

Representing items in a list 

f:selectItem

Represents one item in a list of items 

f:selectItems

Represents a set of items 

Validator

f:validateDoubleRange

Adds a DoubleRangeValidator to a component

f:validateLength

Adds a LengthValidator to a component

f:validateLongRange

Adds a LongRangeValidator to a component

f:validator

Adds a custom validator to a component

f:validateRegEx

Adds a RegExValidator to a component

f:validateBean

Delegates the validation of a local value to a BeanValidator

f:validateRequired

Enforces the presence of a value in a component 

Ajax 

f:ajax

Associates an Ajax action with a single component or a group of components based on placement 

Event 

f:event

Allows installing a ComponentSystemEventListener on a component

These tags, which are used in conjunction with component tags, are explained in other sections of this tutorial. Table 7–9 lists the sections that explain how to use specific core tags.

Table 7–9 Where the Core Tags Are Explained

Tags 

Where Explained 

Event handling tags 

Registering Listeners on Components

Data conversion tags 

Using the Standard Converters

facet

Using Data-Bound Table Components and Laying Out Components with the h:panelGrid and h:panelGroup Tags

loadBundle

Displaying Components for Selecting Multiple Values

param

Displaying a Formatted Message with the h:outputFormat Tag

selectItem and selectItems

Using the f:selectItem and f:selectItems Tags

Validator tags 

Using the Standard Validators