Overriding JSF renders
The main responsibilities of a Renderer
consists of generating the appropriate client-side markup, such as HTML, WML, and XUL, and converting information coming from the client to the proper type for the component.
JSF provides a set of built-in renders and has the capability to extend them with custom behavior. If you consider a proper workaround to override a built-in render, then perform the following steps:
Extend the desired built-in renderer (for example,
Renderer
,TextRenderer
,LabelRenderer
,MessagesRenderer
, and so on).Override the built-in renderer methods.
Configure the new renderer in
faces-config.xml
or using the@FacesRenderer
annotation.
Well, let's see some examples of writing a custom render. For example, let's suppose that we have three attributes (player-nickname
, player-mother-name
, and player-father-name
) that we want to use inside the <h:inputText>
tag. If you try to write the following code:
<h:inputText value="Rafael Nadal" player-nickname...