- Introduce JSF.
- Learn where JSF came from.
- Understand why and where you should think about using JSF.
- Compare JSF to other frameworks.
- Explore JSF components and makeup at a high level.
This first JSF chapter gives an overview of what JSF is, where it came from and generally how it works from a high level. You examine JSF’s makeup in more detail in subsequent chapters.
What is JavaServer Faces(JSF)?
According to many definitions, including one from Sun Microsystems , JSF is a Java framework for building user interfaces. Specifically for developing Web applications rendered in HTML, but it can also be used to develop user interfaces for other displays. For example, JSF can be used to render WML, XUL, or mobile Java Micro Edition client applications.
JSF is also a specification. JSR-127 is managed by the Java Community Process (JCP). It defines the organization and structure of a framework that multiple vendors can implement. By the way, JSR-252 defines the latest version of JSF (version 1.2). JSF 1.2 is part of JEE 5. JSF is mandated in order to be a full JEE 5 container.
JSF has been described as…
- Swing for the Web or Swing for the server-side; referring to its UI components and event handling model.
- Visual Basic for Java; referring to the fact that JSF lends itself to visual development tools/environments to aid in the development of UIs.
- Struts++; referring to its resemblance to other model-view-controller (MVC) application frameworks like Struts and Tapestry.
- The Model is the business rules and most commonly how the persistent information (Database) is changed.
- The View is the presentation, or how the application looks.
- The Controller represents how the application reacts to user input.
- The model can remain unchanged when the view changes.
- The model and view can use completely different technologies.
- The Controller (in a way) serves as the glue between the model and the view.
Where did JSF come from?
JSF was started by an expert group in May 2001.
- The specification and reference implementation (by Sun) was first released in March 2004.
- Version 1.1 was made available in May 2004.
- Version 1.2 was just released in August 2006.
It developed from a need to provide rapid user-interface development to server-side Java. JSPs and servlets, while very scalable and portable, take a long time to develop. JSF is intended to be a direct competitor to ASP. NET – providing tools that “simplify building Java Server application GUIs.”
Why use JSF?
The 8 goals of JSF, as stated right in the JSR, are:
- Create a standard GUI component framework which can be leveraged by development tools to make it easier for tool users to both create high quality GUIs and manage the GUI's connections to application behavior.
- Define a set of simple lightweight Java base classes for GUI components, component state, and input events. These classes will address GUI lifecycle issues, notably managing a component's persistent state for the lifetime of its page.
- Provide a set of common GUI components, including the standard HTML form input elements. These components will be derived from the simple set of base classes (outlined in #1) that can be used to define new components.
- Provide a JavaBeans model for dispatching events from client-side GUI controls to server-side application behavior.
- Define APIs for input validation, including support for client-side validation.
- Specify a model for internationalization and localization of the GUI.
- Automatic generation of appropriate output for the target client, taking into account all available client configuration data, such as browser version, etc.
- Automatic generation of output containing required hooks for supporting accessibility, as defined by WAI (Web Accessibility Initiative).
- Java Server Pages (JSP). If you are familiar with JSPs you will find JSF “plumbing” to be similar.
- Client-side development. If you are familiar with Swing, many of the UI components and the event model will seem familiar.
- Server-side frameworks like Struts. JSF is built with a similar architecture.
JSF applications are standard Java Web applications.
- Requires a standard Web container.
- The Web container must support Servlet specification 2.3 or better.
- The Web container must also support JSP specification 1.2 or better.
- JDK 1.4.1 or higher.
While not absolutely required, you will want a JSF supportive IDE. Many popular IDEs (RAD, MyEclipse, NetBeans, JBuilder, JDeveloper, Studio Creator) now offer JSF development tools. Many of these include WYSIWYG/drag-and-drop editors. Most IDE and app server vendors still provide a JSF 1.1 implementation.
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.