Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

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:

  1. Extend the desired built-in renderer (for example, Renderer, TextRenderer, LabelRenderer, MessagesRenderer, and so on).

  2. Override the built-in renderer methods.

  3. 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...