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.
You do not need to create a custom component in these cases:
You simply need to manipulate data on the component or add application-specific functionality to it. In this situation, you should create a backing bean for this purpose and bind it to the standard component rather than create a custom component. See Backing Beans for more information on backing beans.
You need to convert a component’s data to a type not supported by its renderer. See Using the Standard Converters for more information about converting a component’s data.
You need to perform validation on the component data. Standard validators and custom validators can be added to a component by using the validator tags from the page. See Using the Standard Validators and Creating a Custom Validator for more information about validating a component’s data.
You need to register event listeners on components. You can either register event listeners on components using the valueChangeListener and actionListener tags, or you can point at an event-processing method on a backing bean using the component’s actionListener or valueChangeListener attributes. See Implementing an Event Listener and Writing Backing Bean Methods for more information.