background image

When to Use a Custom Component

<< Creating Custom UI Components | When to Use a Custom Renderer >>
<< Creating Custom UI Components | When to Use a Custom Renderer >>

When to Use a Custom Component

Determining Whether You Need a Custom Component or
Renderer
The JavaServer Faces implementation supports a rich set of components and associated
renderers, which are enough for most simple applications. This section helps you decide
whether you need a custom component or custom renderer or instead can use a standard
component and renderer.
When to Use a Custom Component
A component class defines the state and behavior of a UI component. This behavior includes
converting the value of a component to the appropriate markup, queuing events on
components, performing validation, and other functionality.
You need to create a custom component in these situations:
You need to add new behavior to a standard component, such as generating an additional
type of event.
You need to aggregate components to create a new component that has its own unique
behavior. The new component must be a custom component. One example is a date chooser
component consisting of three drop-down lists.
You need a component that is supported by an HTML client but is not currently
implemented by JavaServer Faces technology. The current release does not contain standard
components for complex HTML components, such as frames; however, because of the
extensibility of the component architecture, you can use JavaServer Faces technology to
create components like these.
You need to render to a non-HTML client that requires extra components not supported by
HTML. Eventually, the standard HTML render kit will provide support for all standard
HTML components. However, if you are rendering to a different client, such as a phone, you
might need to create custom components to represent the controls uniquely supported by
the client. For example, some component architectures for wireless clients include support
for tickers and progress bars, which are not available on an HTML client. In this case, you
might also need a custom renderer along with the component; or you might need only a
custom renderer.
Determining Whether You Need a Custom Component or Renderer
The Java EE 5 Tutorial · September 2007
410