An introduction to JSF
JSF(JavaServer Faces) is a recently originated framework by Sun Microsystems based in Java. A standard developed by JCP (java community process), it holds compliance to any application Server in Java EE such as GlassFish, Jboss or Oracle's Weblogic. It is meant for designing and building rich web applications. It makes the work simple for programmers/web developers as it provides an approach which is component-centric and supports listeners on the front end components. It facilitates the development of extensive web user-interfaces and is now an industry accepted standard for building user interfaces on the server side in Java EE.
For front end and corporate developers, building user interfaces in JSF is as simple as dragging and dropping components onto a page. System developers are fond of it as the robust and rich API exposed by JSF provides them a great deal of flexibility in programming and unsurpassed power by using the well established and reliable MVC (model-view-controller) design pattern as a core ingredient architecture. JSF is an independent stand alone framework for web which can also be paired up with bean containers like Spring framework. Applications that use JSF can be created, without having to add other external dependencies or libraries in the project.
JSF with Ajax
JavaServer Faces is a component-based design model for front end. It uses XML files, which are referred to as Facelets views. Any server side request is processed by FacesServlet. It directs to the view template which is the most appropriate with respect to the request, builds up a component tree, performs actions on events and sends response at the client side (typically as HTML). The components of user interface save their state with every request, and it is restored at the next instance of time when the view is created. JSF can render output in multiple formats and hence can be used in conjunction with Ajax to develop rich internet applications. JSF 2.0 has built-in support for Ajax and has simplified the development process.
The configuration files needed for setting up a JSF application are :
Also Read: Getting familiar with design patterns in Java
Why is JSF preferred to struts
Javaserver Faces is a more commonly used framework as compared to struts because it has an extensible and a flexible UI component-based model which has an extensive range of components, both simple and complex and an API that specifies how a component can be rendered in different ways. It allows developers to create their own custom components too. Secondly, it supports a event-and-listener model that specifies handling of events that are triggered when the component(s) are activated. Also, it can validate the component data and map it to the model.