×
☰ See All Chapters

JSF UI Components

What is Component?

  • In Software field a component is a self-contained piece of software with a well-defined usage contract that is used by another piece of software. 

  • Components in JSF are elements like text box, button, table etc.. That is used to create UI of JSF Applications. These are objects that manage interaction with a user.   

  • A user interface component (UI component) is a specific type of component that displays user interface content which the user can modify over time. This content ranges from simple input fields or buttons to more complex items, such as trees or data grids. In JavaServer Faces, the term UI component technically refers to a specific class that defines the core behavior of the component regardless of how it appears (is rendered) to the client. 

  • Text box, button are examples of simple components.  A component containing many components inside it is called a compound component. Table, data grid are examples of compound components. 

  • UIComponent class is a super class of all UI components classes like UIForm, UIInput, UIPanel, UISelectItem etc… Different components such as a Renderer, a tag handler, a Validator, a Converter, and so on work together to enable the overall UI component to run in a Faces deployment environment. 

  • Renderer, a tag handler, a Validator, a Converter etc.. are non-visual helper components for UIComponent. The helper components, more correctly known as “attached objects” because the UIComponent instance maintains a Java object reference to them, are also considered Faces components, but they are not, themselves, UI components because they don’t help in rendering the component visually, they are just components. 

A Renderer is a class present in a package javax.faces.render. Renderer produces HTML output, reflecting the component state. For example, the renderer for the component that corresponds to the h:inputText tag produces the following output:

<input type="text" name="unique ID" value="current value"/>

This process is called encoding.

  • Renderer knows how to render JavaServer Faces-UIComponent instances for a specific client Hence JSF has automatic generation of appropriate output for the target client, taking into account all available client configuration data, such as browser version, etc. 

  • Tag Handlers are classes which handles JSF tags. Each tag in JSF has an associated tag handler class. When the facelet is read, the tag handler classes are executed. 

Components Types
There are two types of Components in JSF

  1. Standard UI Components 

  2. Custom UI Components 

Standard UI Components
It contains basic set of UI components like text fields, check boxes, list boxes, panel, label, radio button etc. These are called standard components
Custom UI Components
JSF let you create and use your own set of reusable components. These components are called custom components.

 

 

 


All Chapters
Author