Roopak Neevan's Blog

JSF Tips : When to Customize UI component

Posted by: Naveen Kapoor on: December 26, 2008

 Java Server Faces is a Java framework for building user interfaces for Web applications. It simplifies the development of the user interface, which is one of the more difficult parts of Web development. JSF technology offers a basic set of standard, reusable UI components which allows developers to quickly and easily build User Interface for web applications. But application may requires a new functionality or It may need an entire new component and JSF allows developer to extent the standard UI Components or to create new custom components.

When user need custom UI Components in JSF

Users must need to identify if they really need to create custom components taking few points into consideration

  • 1) User must check if JSF community may already have the solution to your problem.
  • 2) If user need to add new functionality to the standard components
  • 3) You need to aggregate components to create a new component that has its own unique behavior.

When user need custom Renderer

User need to ensure if the component class performs the below operations

  • 1) Encoding: Converting current local values of the component to display the in the response
  • 2) Decoding: Where the incoming request parameters are converted to the component local values

JSF supports two ways to handle Decoding and Encoding

  • Direct implementation: Where the component class itself will implement decoding and encoding.
  • Delegated implementation: Where user have to implement decoding and encoding in a different renderer class.

Using Delegated implementation user can associate custom components with the different renderers.

Ingredients of a JSF UI Components

The various ingredients that constitute a JSF UI component are as below 

  • UIComponent Class: This is the Java class that represents the core behavior of the component. This class is derived from either UIComponentBase or directly from UIComponent. You can also extend from an existing base UIComponent class, such as UIInput.
  • UIComponentTag Class: This is a JSP tag handler class that allows the UI component used in a JSP. It associates a separate Renderer class with a UIComponent class. And also implements setProperties method that stores the ValueExpression or MethodExpression object for each component property so that the component class can retrieve the expression object later.
  • Tag Library Descriptor File: A standard J2EE JSP tag library descriptor (TLD) file that associates the tag handler class with a tag in a JSP page.
  • Renderer Class: A class that contains code to render a UIComponent. It can also contain code for encoding and decoding.
  • Associated Helper Classes: A collection of standard or custom helper classes such as Converter, Validator, and ActionListener.

To understand custom UI Components lets divide the concepts into three parts.

1)       Custom Tags

2)       Custom components using standard UI Components

3)       Custom components using Renderer classes 

Requirement for Custom Tags, Custom Components and  Renderers

Custom Item Component class Component tag class Renderer Class Tag Lib Desc. (TLD)
Custom Tag

Y

Y

x

Y

Custom Component / Direct Implementation

Y

Y

x

Y

Renderer / Delegated Implementation

Y

Y

Y

Y

 

 

Leave a Reply


  • mudassir: thanks ............. .................... did a great job for guiding
  • Anand V: This is an wonderful effort !! It really helps lots of parents to understand the procedures and shed light over the minor passport myths. My hea
  • Deepak Dandriyal: Very Good MAN thanks for sharing,,,,,,,,,,god bless