Wednesday, July 10, 2013

JSF, JSF 2.0 Overview

This blog is for the beginners of JSF to get an overview of the concepts.

In this blog, I am going to touch the following concepts.


1. What is JSF
2. JSF Terminology
3. JSF life cycle
4. Facelets - Included in JSF 2.0
5. Custom components
6. Ajax
7. Component libraries
8. Examples
9. Advantages
10. References 

What is JSF
JavaServer Faces (JSF) is a Java specification for building component-based user interfaces for 
web applications.
It's a standard Java EE web framework.
Well-designed and easy-to-use component-based webframework.
JSF is based on well established MVC design pattern.
There are as far two (major) JSF implementations, namely Oracle Mojarra and Apache MyFaces.

JSF Terminology
The following terminology is used in JSF
1. UI Components 
2. Renderer 
3. Validator 
4. Backing Beans 
5. Converter 
6. Events and Listeners 
7. Messages 
8. Navigation

*Backing Beans
Backing Beans are specialized JavaBeans that collect values from UI Components and implement the event
listeners. Backing Beans control and define the interaction between the UI and the model.
    Ex: *WIP*

JSF life cycle
There are 6 phases in JSF application lifecycle.
1) Restore view
2) Apply request values
3) Process validations
4) Update model values
5) Invoke application
6) Render response
*WIP*

JSF life cycle

Facelets
Facelets is a view technology for JSF.
Support for code reuse through templating and composite components.
Faster compilation time.
High performance rendering.

Custom components
In JSF, a component is a group of interacting classes that together provide a reusable piece of web-based
user interface code. 
A component is made up of three classes that work closely together.
1) Renderer - which creates the client-side representation of the component and takes any input
     from the client and transforms it into something the component can understand
2) UIComponent subclass - This class is responsible for the data and behavior of the component on
     the server side.
3) JSP custom action – The main functions of this class are to allow for configuration of the
    component in a JSP and to attach a particular renderer to the component.




Ajax
By using ajax support you can update JSF elements (h:outputText, h:inputText, h:selectOneMenu, etc.) from
client side itself. You don’t have to write JavaScript
f:ajax tag is used in JSF.

Component libraries
JSF component libraries just adds extra features on top of the basic implementation, They are like
skinnability, ajaxability, enhanceability.
There are lot of JSF component libraries

Advantages
1. JSF is based on well established Model-View-Controller (MVC) design pattern. 
2. Applications developed using JSF frameworks are well designed and easy to maintain then any other
    applications developed in JSP and Servlets.
3. JSF provides standard, reusable components for creating user interfaces for web applications.
4. JSF provides many tag libraries for accessing and manipulating the components.
5. JSF is a specification and vendors can develop the implementations for JSF.

References
JSR-000127 JavaServerTM Faces (Final Release) - http://jcp.org/aboutJava/communityprocess/final/jsr127/