JavaServer Faces (JSF)

JavaServer Faces (JSF) is a Java-based Web application framework which establishes the standard for building server-side user interfaces. The JSF specification was developed under the Java Community Process or JCP as JSR 127, which defined JSF 1.0 and 1.1, and JSR 252 which defined JSF 1.2. Current specification JSF 2 is developed as JSR 314. With the contributions of the expert group, the JavaServer Faces APIs are being designed so that they can be leveraged by tools that will make web application development even easier.

It is also a MVC web framework that simplifies construction of user interfaces (UI) for server-based applications by using reusable UI components in a page. JSF 2 uses Facelets as its default templating system. Other view technologies such as XUL or plain Java can also be employed. JSF 2 includes support for graceful degradation when JavaScript is disabled in the browser.

JavaServer Faces technology includes:

  • A set of APIs for representing UI components and managing their state, handling events and input validation, defining page navigation, and supporting internationalization and accessibility.
  • A JavaServer Pages (JSP) custom tag library for expressing a JavaServer Faces interface within a JSP page.

Designed to be flexible, JavaServer Faces technology leverages existing, standard UI and web-tier concepts without limiting developers to a particular mark-up language, protocol, or client device. The UI component classes included with JavaServer Faces technology encapsulate the component functionality, not the client-specific presentation, thus enabling JavaServer Faces UI components to be rendered to various client devices.

By combining the UI component functionality with custom renderers, which define rendering attributes for a specific UI component, developers can construct custom tags to a particular client device. As a convenience, JavaServer Faces technology provides a custom renderer and a JSP custom tag library for rendering to an HTML client, allowing developers of Java Platform, Enterprise Edition (Java EE) applications to use JavaServer Faces technology in their applications.

Ease-of-use being the primary goal, the JavaServer Faces architecture clearly defines a separation between application logic and presentation while making it easy to connect the presentation layer to the application code. This design enables each member of a web application development team to focus on his or her piece of the development process, and it also provides a simple programming model to link the pieces together. For example, web page developers with no programming expertise can use JavaServer Faces UI component tags to link to application code from within a web page without writing any scripts.

JSF is a rich featured framework of JAVA technology. JSF provides a set of standard features that makes it a powerful and standard among the existing technologies available for the development of web application based on Java Technologies.

JavaServer Faces provides the following main features:

  • Page navigation specification
  • Standard user interface components like input fields, buttons, and links
  • User input validation
  • Easy error handling
  • Java bean management
  • Event handling
  • Internationalization support

 

Facelets (that was designed specifically for JavaServer Faces) was adopted as the official view technology for JSF 2.0. This eliminates the life-cycle conflicts that existed with JSP, forcing workarounds by Java developers. Facelets allows easy component/tag creation using XML markup instead of Java code, the chief complaint against JSF 1.x. 

JSF 2 provides a fine infrastructure to implement a rich user interface. It would not be right to compare it with Spring or Struts2 because they are more of an ecosystem where many technologies interplay. JSF 2 is focused in one aspect of Web development and there it performs pretty well. The flexible component-centric behavior of JSF 2 provides a fertile ground for fabrication of the UI components. JSF 2 is not the only one. There are other component-based frameworks, such as Tapestry and Wicket. JSF 2 is particularly suitable for rapid Web interface development.