JavaServer Faces is a standard Java framework for building user interfaces for Web applications.
It simplifies the development of user interfaces for Java Web applications in the following ways:
-> It provides a component-centric, client-independent development approach to building Web user interfaces, thus improving developer productivity and ease of use.
-> It simplifies the access/management of application data from the Web user interface.
-> It automatically manages the user interface state between multiple requests.
JSF combines an MVC design approach with a powerful, component-based UI development framework that greatly simplifies Java EE Web development while using existing markup and servlet technologies
JSF technology is based on the Model View Controller (MVC). JSF application is really just a standard Java EE Web application with a few specific configurations:
web.xml-It has entry for faces controller servlet.
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>FirstJsfProject</display-name> <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> </web-app>
faces-config.xml-It is optional. It is used for configuration of all elements of a JSF application. If we are not using it then we can use annotations. JSF has Java annotations for nearly everything that can be put in to the faces-config.xml
<?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd" version="2.2"> </faces-config>
When running an application in a container that does not provide built-in support for JSF, the libraries composing the JSF implementation must be included in WEB-INF/lib.
Building JSF applications with XHTML is done by using JSF-enabled Facelets tag libraries. For an XHTML page to be JSF-enabled, it must first contain JSF XML namespace directives provided by a JSF implementation.
The following namespace directives are for the Core and HTML libraries available from all JSF implementations:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
Model- Beans which carries data.
View- UI which can be implemented using xhtml pages.
Controller- Faces Servlet which act as a controller and specified in web.xml
next