Java Reference
In-Depth Information
3. Register the component.
4. Create an event handler if your component generates events.
5. Create a tag library descriptor (TLD) that defines the custom tag.
See “ Registering a Custom Component on page 167 and “ Registering a Custom Renderer
with a Render Kit on page 165 for information on registering the custom component and
the renderer. The section “ Using a Custom Component on page 121 discusses how to use
the custom component in a JavaServer Faces page.
Creating Custom Component Classes
As explained in “ When to Use a Custom Component on page 97 , a component class
defines the state and behavior of a UI component. The state information includes the com-
ponent's type, identifier, and local value. The behavior defined by the component class
includes the following:
• Decoding (converting the request parameter to the component's local value)
• Encoding (converting the local value into the corresponding markup)
• Saving the state of the component
• Updating the bean value with the local value
• Processing validation on the local value
• Queueing events
The javax.faces.component.UIComponentBase class defines the default be-
havior of a component class. All the classes representing the standard components extend
from UIComponentBase . These classes add their own behavior definitions, as your
custom component class will do.
Your custom component class must either extend UIComponentBase directly or extend
a class representing one of the standard components. These classes are located in the
javax.faces.component package and their names begin with UI .
If your custom component serves the same purpose as a standard component, you should
extend that standard component rather than directly extend UIComponentBase . For ex-
ample, suppose you want to create an editable menu component. It makes sense to have
this component extend UISelectOne rather than UIComponentBase because you
can reuse the behavior already defined in UISelectOne . The only new functionality
you need to define is to make the menu editable.
Search WWH ::




Custom Search