|< Day Day Up >|
1.1 What Is JavaServer Faces?
JavaServer Faces (JSF) simplifies development of sophisticated web application user interfaces, primarily by defining a user interface component model tied to a well-defined request processing lifecycle. This allows:
More specifically, JSF is a specification with implementations offered by multiple vendors. It defines a set of user interface (UI) components—basically, a one-to-one mapping to the HTML form element set plus a few extras—that can be used right out of the box, as well as an Application Programming Interface (API) for extending the standard components or developing brand new components. Validators attached to the components validate user input, which is then automatically propagated to application objects. Event handlers are triggered by user actions, such as clicking on a button or a link, and can change the state of other components or invoke backend application code. The outcome of the event processing controls which page is displayed next, with help from a pluggable navigation handler.
While HTML is the markup language of choice for most web applications today—and used for most examples in this book—JSF is not limited to HTML or any other markup language. Renderers that are separate from the UI components control the actual markup sent to the client, so the same UI component coupled with different renderers can produce very different output—for instance, either HTML and WML elements. If you're familiar with Swing, think "pluggable look and feel" (PLAF).
JSF gives you lots of flexibility in how you actually develop the user interface. All JSF implementations are required to support JavaServer Pages (JSP) as a presentation layer technology, with JSF components represented by JSP custom action elements (also commonly known as custom tags). The JSF API, however, is flexible enough to support other presentation technologies besides JSP. For instance, you can use pure Java code to create JSF components, which is similar to how a Swing UI is developed. Alternatively, you can bind JSF components to nodes in templates described by plain HTML files, the approach explored by projects such as Barracuda/XMLC and Tapestry. I use the JSP layer for most examples in this book because it's the only approach that's completely specified in JSF 1.0, but I also show examples of other approaches.
If you've developed Java web applications for some time, you've probably heard of (and have likely used) application frameworks like Apache Struts (http://jakarta.apache.org/struts/) or Maverick (http://mav.sourceforge.net/). Even though JSF overlaps a bit with the features offered by frameworks like these (for instance in the areas of validation and navigation support), it's also designed to play well with them. I discuss the options available for Struts applications to use a JSF user interface in Chapter 12, so you'll see exactly how JSF fits together with this popular application framework.
|< Day Day Up >|