Introduction
The evolution of web development began with Servlet technology, which was used to directly generate HTML pages for displaying it on a web browser. Next, came JSP, which is a hybrid between an HTML Page and a Servlet. JSP pages enforced separation of the view and application logic. JSF or Java Server Faces is the current technology used for rapid development of web applications. It is designed to build MVC based web applications.
JSF is a component-based framework. The main components of JSF technology include:
An API for User Interface (UI) Components with a provision for:
- State Management
- Server-Side Validation
- Data Conversion
- Page Navigation specification
Standard UI components include:
- Input fields
- Buttons
- Links and others
User input validation through standard and custom build validators:
- Error Handling
- Java Bean Management
- Event Handling
- Support for Internationalization
JSF in UI Framework
One common method of web application development is to use JSP and Servlets. These technologies do not provide Java Swing-like components to build dynamic Web applications. The developers often created their own customized mechanisms to store the state of web applications and also they had to code methods to implement event handling. Many Java developers wanted a mechanism that will allow them to perform the following:
- Facility to implement custom UI components and add or remove them dynamically.
- Provide UI support to various types of clients such as PDA , mobile phones, and so on.
- Using a swing-like event model that would trap events fired by components or controls in Web pages.
JSF overcame these deficits and provided a standard set of APIs for satisfying the above-mentioned drawbacks. It provided the new standard that has a powerful mechanism to built interactive web applications. JSF offers pluggable functional components at various UI levels. JSF allows each of its pluggable components a special implementation such that they may provide a connection point between JSF and an external framework on which an earlier application might be based.
JSF Advantages
- A rich collection of controls
- Support for event-based notification
- Support for Internationalization and Localization
- Variable representation of UI through the use of renderers
- Architecture for processing component data, managing component state, validating user input and handling events
UI Component Model
The user interface of JavaServer Faces applications uses configurable, reusable elements of JavaServer Faces UI components. The UI Component Model of JSF comprises of UI component classes, rendering model, event model, data conversion model, and data validation model as shown in the figure below:

Figure 1: JSF User Interface Model
UI Component Classes
The UI Component classes in JSF are used as building blocks to create simple as well as complex user interface for web applications
JSF specification defines a set of standard UI component classes and behavioral interfaces. These classes and interfaces store the state information about the various JSF controls. Further, they enable maintain references to various objects and handling of events fired by these controls. These classes help the component to rendered in different ways and are derived from UIComponentBase class.
UICommand
The UICommand component represents command components such as buttons and links. These controls perform an action when activated which is achieved through an ActionEvent and ActionListener interface. The representation of a UICommand component can be <h:commandButton> or <h:commandLink>.
<h:commandButton> element represent command buttons such as submit or reset . The syntax for using a <h:commandButton> is shown below:
Syntax
- <h:commandButton [id=”<ID>”] [binding=”<ComponentBinding>”] [rendered=”<true|false>”]
- [immediate=”<true|false>”]
- [image=”<PathOfImage>”]
- [type=”<submit|reset>”]
- [value=”<Value>”] [actionListener=”<ActionListener>”]
- />
Where,
- id: is the component identifier for the current component and it must be unique within the closest parent component.
- binding: is the value expression for a backing bean property to which the component is bound to.
- renedered: indicates if the component should be rendered or not during the Render Response phase. Its default value is true.
- immediate: If this flag is set to true then the moment the component is activated, notifications should be delivered to the listeners and action taken during the same Apply Request Phase rather than in Invoke Application Phase.
- image: is a path or URL of an image to be displayed for the action.
- value: is the current value of the component.
- type: is the type of button to be created. By default, a submit button is created.
- actionListener: is the method expression that represents an action listener method to be notified on activation of the component.
UIPanel
This component is used as a layout container component for other components. The <h:panelGrid> is the element that represents a container table or <h:panelGroup>element creates a container to a group of components under one parent.
The syntax for <h:panelGrid> element is:

Join the conversation! Your thoughts help the community grow.