JSF Tutorial For Beginners
In this section you will learn about the JSF framework.
This section describes all the aspects of JSF in such a way that a user who wants to start reading JSF and they wants to make their carrier in JSF. This section is also for the experienced who is already working on JSF. In this page we will cover the topics like what is JSF, need to JSF, features of JSF, components of JSF, architecture of JSF, life-cycle of JSF, benefits of JSF, JSF tags, JSF listeners and events, JSF integration, validation in JSF, how to download JSF,
What is JSF ?
JSF (JavaServer Faces) is a Framework for developing the web applications based on the Java technology. This framework is developed by the Java Community Process(JCP, community of web application experts). JSF provides the facility to develop web applications in a component oriented and event driven way that runs on the server side. JSF also allows to build the server-side user interfaces on the MVC (Model-View-Controller) design pattern.
Need To JSF
When a web application developer uses the existing technologies like JSP and Servlet for developing the complex web applications they suffer with the following problem :
- Repetition of Code. JSF provided the facility of reusability of code.
- Problem of working with HTTP : The problem of working with HTTP is that if an application is not able to map the HTTP request to component specific event handling on server then it may cause to security problem. JSF has resolve this problem.
Features Of JSF
JSF has the various features these are as :
- Reusability of Code.
- It provides the better security while requesting through HTTP.
- It facilitate the encapsulation.
- JSF facilitate to integrate with Unified Expression Language.
- JSF provides set of HTML and web-application specific UI components.
Components of JSF are JSF API, and JSP Custom Tag Libraries
Architecture of JSF
JSF is based on MVC design pattern. It allows to separate your codes from each other i.e. you can write your model, view and controller as loosely coupled. In the core of the JSF Servlet runs. It contains JavaBeans components as model, validators, event handler, navigation rules, JSP custom tag library, UIComponents, Internationalization support.
Like an other web applications developed in other Java technologies, JSF enabled web application also follows a certain life-cycle for every request and response. Life-Cycle of JSF is divided into six phases these are as :
- Restore View Phase
- Apply Request Values Phase
- Process Validations Phase
- Update Model Values Phase
- Invoke Application Phase
- Render Response Phase
Benefits Of JSF
JSF has various benefits these are as :
- The MVC architecture facilitate to separate the behavior from presentation.
- JSF provides the facility to link the separate pieces of the development process to a single piece by offering a simple programming model.
- JSF provides the built-in support of Ajax, bookmarking, and page-load actions.
- Provides more security.
- Reusability of codes.
JSF provides various tags for performing operations like JSF table tags, JSF listener and event tags, JSF converter tags, JSF validator tags, JSF ajax tag, etc.
JSF Listeners And Events
In JSF for event handling various built-in tags are provided. A user can use it for handling the events and listening the listener. For example, actionListener, valueChangeListener, setProperyActionListener, phaseListener, event.
Validation In JSF
In JSF to validate data various of built-in tags are provided. A user can use it for validating the data. For example, validateDoubleRange, validateLength, validateLong, validateRegex, validateRequired etc. A user can create its own validatior using Validator interface and @FacesValidator.
JSF can be integrated with other frameworks like, Spring, JDBC etc.
You can download JSF from the following link http://javaserverfaces.java.net/download.html.