Java Reference
In-Depth Information
Facelets Enhancements
There have been a handful of updates to the Facelets implementation for JSF 2.2. Improvements and updates include
the following:
The ability to omit XML taglib files for custom components
Facelets resource resolver annotation
This section covers each of these updates briefly and includes examples of each.
Exclude XML from Custom Components
The creation of custom components just got easier with the JSF 2.2 release. In previous versions, Facelets required the
creation of a *-taglib.xml file that contained the name for the component. Once again, we have been mixing XML
configurations into Java applications, making management more tedious. With the release of JSF 2.2, it is now possible
to get rid of the taglib XML and use the @FacesComponent annotation instead, specifying the createTag attribute.
The @FacesComponent annotation should be placed on the custom component class. Table 2-4 lists possible
attributes. To omit the taglib XML, the createTag attribute must be set to true .
Table 2-4. @FacesComponent Attributes
Set to true to make component directly usable via a tag on a Facelet.
Optional tag name.
Optional explicit namespace for tag. If omitted, the namespace of will be used.
Custom-component fully qualified name.
An example custom component class is as follows:
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
@FacesComponent(value="components.SpecialComponent", createTag=true,
namespace=" " )
public class SpecialComponent extends UIComponentBase {
public String getFamily() {
// Do something here throw new UnsupportedOperationException("Not supported yet.");
//To change body of generated methods, choose Tools | Templates.
Search WWH ::

Custom Search