Saturday, 26 May 2012

JSF Component



JSF Components

For next few blogs we will be discussing on In build Jsf component. How these component can be used in the application and the attributes they support. We will also see how to create custom and composite tags. But before we start let us see what really a component is.

Jsf is a component driven framework. A component is a unit which perform a specific task and can be can be deployed independently and is subject to composition by third parties.A Jsf UI component, or control, is a component that provides specific functionality for interacting with an end user. Classic examples include toolbars, buttons, panels, and calendars”.

A jsf Component fuctionality can be discribe in three steps:-
  1. Converting incoming request parameters from the markup(Html) to the values of the component.
  2. Hold the values for process like converstion , validation and bussiness logic action.
  3. Converting the current values of the component back into the corresponding markup, that is, HTML.


Thus JSF components consist of two parts: the component and the renderer.
The JSF Component class defines the state and behavior of a UI component; a renderer defines how the component will be read from the request and how it will be displayed -- usually though HTML.The renderer converts the values of the component to appropriate markup. Event queuing and performance validation happen inside the component.



Let us look take an example . The HtmlInputText component can be divded into two parts



  1. <h:inputText> tag which is responsible for holding the information and behavior .
  2. A TextRenderer which is reponsible for Decoding the request from html to component value and encoding the component values into html standards.

In Jsf Life Cycle you can see the phase where the encoding and decoding happens.



JSF Tags
JSF application typically uses JSP pages to represent views. JSF provides useful special tags to enhance these views. Each tag gives rise to an associated component. JSF provides 43 tags in two standard JSF tag libraries:
  1. JSF Core Tags Library and
  2. JSF Html Tags Library
Even a very simple page uses tags from both libraries.
<%@ taglib uri=”http://java.sun.com/jsf/core“ prefix=”f” %>
<%@ taglib uri=”
http://java.sun.com/jsf/html“ prefix=”h” %>
Here we will see the Jsf Html Tags Libraries . We will discuss the Jsf core libraries in the further blogs.

JSF Html Tags:
Jsf Html tags can be divided into following categories:

1. Inputs :
     inputText :- creates text input control (single line)
     inputTextarea :- creates text input control (multiline)
     inputHidden :- creates hidden field
       inputSecret :- creates input control for password

2. Outputs :
       outputFormat :- creates outputText, but formats compound     messages
      outputLabe l:- creates label
      outputLink :- creates anchor
      outputText :- creates single line text output 

3. Commands :
       commandButton:- creates button
       commandLink:- creates link that acts like a pushbutton

4. Selections : 
       selectBooleanCheckbox :- creates checkbox
       selectManyCheckbox:- creates set of checkboxes
       selectManyListbox :- creates multiselect listbox
      selectManyMenu:- creates multiselect menu
       selectOneListbox:- creates single select listbox
       selectOneMenu:- creates single select menu
       selectOneRadio:- creates set of radio buttons

5.  Layouts :
       form :- creates a form
       panelGrid :- creates html table with specified number of columns
       panelGroup :- used to group other components where the specification 
                         requires one child element.   

6. Data Table :
      dataTable:- creates a table control
       column:- creates column in a dataTable

7.  Message :
        message:- displays the most recent message for a component
        messages:- displays all messages














2 comments: