Monday, April 16, 2012

What is Java Server Faces (JSF) and jsf life cycle

JSF stands for Java Server Faces. JSF is MVC (Model - View - Controller) based user interface ( UI ) Java Web framework which has server-side components for building Java web applications user interfaces. JSF provides a well defined programming model and various tag libraries. With the help of JSF, Java-ee web developers can easily and quickly build enterprise java web applications.
JSF provides ease-of-use in the following ways:

  • Provides reusable UI components to construct User interfaces.
  • Provides facility in application data migration to and from the UI
  • Provides facility to manage UI state across server requests
  • Provides facility to wire client side events to server side application code
  • Provides provision for building and reusable of custom UI components
  • Provides encapsulation of the differences in markup across different browsers and client.
  • Provides support for form processing
  • Provides page-to-page navigation handling in response to UI events and model interactions.
Currently JSF has below mentioned 5 specifications which have different features and improvements
JSF-2.2 , JSF-2.1, JSF-2.0, JSF-1.2 , JSF-1.1

What is JSF, What is JSF MVC Architechure diagram, jsf tutorials, java server faces tutorials, java web action, java web development, web applications development, jee jsf architechture, javaserverfaces tutorial, jsf2, jsf 2 tutorial

JSF Request Processing Life Cycle:

Generally Web user interfaces follow a request / response pattern with web servers to display required information on web interfaces. In the case of Web browsers, an initial HTTP GET or HTTP POST request is made to the Web server which responds with a required processed document / data. The web server responses to each of these subsequent requests are usually documents, images, JavaScript files, CSS Style Sheets and other artifacts.
Here we will discuss JSF Faces View Request / Response life cycle. When JSF lifecycle involves in rendering the initial response, processing of initial request, a response for request and any automatically subsequent requests from user interface and their related responses is called a Faces View Request / Response.

Below diagram is of JSF Faces View Request / Response.

What is JSF (Java Server Faces) Request Processing Lifecycle, what is jsf, jsf tutorial, java web development, javawebaction, java web action, what is java server faces, java ee tutorial, java ee training

There are well defined request processing life cycle phases, each Faces View Request/Response goes through these phases. There are three different scenarios for request / response

  1. Non faces request generates faces response
  2. Faces request generates faces response
  3. Faces request generates non faces response

Faces Response:
Faces response is the response which generates by the execution of the Render Response phase of the request processing life cycle.

Non-Faces Response:
None faces response is the response which generates by the execution of the render response phase of the request processing life cycle.

Faces Request:
It is the request that was sent from a previously generated Faces response.

Non-Faces Request:
A request that was sent to an application component like a servlet or JSP page, instead of a Faces view.

Web application may also receive non-Faces requests that generate non-Faces responses. Because such requests do not involve Java Server Faces at all.
Below is the Execute and Render life cycle diagram.

Find JSF tutorials, what is jsf, what is java server faces, jsf2.0, jsf2, javaserverfaces, javawebaction, java web action, java web development, web applications development, j2ee jsf, introduction to jsf

 Sample JSF Web Page Code: 

Below is the example JSF Page code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns=""    
     <title>JSF 2.0 Example Code</title>
     <h3>JSF 2.0 Hello World Example - welcome.xhtml</h3>
     <h4>Welcome #{}</h4> 
        <h:form id="mainForm">
           <h:outputLabel for="enterName" value="Enter Name"/>
           <h:inputText id="enterName" value="#{}"/>
           <h:commandButton value="Say Hello" action="#{sayHelloBean.sayHello}"/>


Please enter relevant question and information.