Home arrow Java & J2EE arrow Page 5 - Introduction to JavaServer Faces, Part 3

Introducing the JSF Application Programming Interface (API) - Java

This chapter has been leading us gently through the JavaServer Faces technology. More importantly, in it, Budi teaches ushow to write an online survey application to get a feel for how this great technology works. This chapter prepares you for the next chapters by introducing the JSF Application Programming Interface (API) and the Application Configuration file. This excerpt comes from chapter two of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983-7, 2004).

  1. Introduction to JavaServer Faces, Part 3
  2. Wrtiting the JSP Files for the Page Navigation Example
  3. Creating the Application Configuration File for the Page Navigation Example
  4. Compiling and Running the Page Navigation Example
  5. Introducing the JSF Application Programming Interface (API)
  6. javax Packages
  7. More javax Packages
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 21
March 22, 2004

print this article



The JSF implementation consists of various interfaces and classes that you can use to write event listeners, validators, custom components, and so on. These interfaces and classes are grouped into the following packages:

  • javax.faces
  • javax.faces.application
  • javax.faces.component
  • javax.faces.context
  • javax.faces.convert
  • javax.faces.el
  • javax.faces.event
  • javax.faces.lifecycle
  • javax.faces.render
  • javax.faces.tree
  • javax.faces.validator
  • javax.faces.webapp
Each package is briefly described in the following sections. Bear in mind that this is only a general introduction to the classes and interfaces in the packages. You will get more details about using these packages in the upcoming chapters, which discuss specific topics related to the classes and interfaces.

The javax.faces Package
The javax.faces package contains the FactoryFinder and FacesException classes. The FactoryFinder is responsible for discovering all factory objects specified in the JSF API. An example of a factory object is the javax.faces.context.FacesContextFactory object, which is responsible for creating FacesContext instances. You probably will never need to use the FactoryFinder class during your career as a JSF programmer.

On the other hand, the FacesException class, which is a subclass of java.lang. RuntimeException, encapsulates general JSF exceptions. You will often need to throw an instance of this class in your JSF classes.

The javax.faces.application Package
The javax.faces.application package contains important classes such as Action, NavigationHandler, and Application, as well as the Message interface. The Action class represents an object that performs a task and can return a String. The NavigationHandler class handles page navigation.

The Application class represents a per-Web-application singleton object to which JSF can register objects that provide functionality required by JSF. As an example, the default NavigationHandler object that manages page navigation is registered with the Application object.

The Message interface represents a validation or other message. For example, a validator will add a Message object to the FacesContext if the validation of the local value of a component fails. The javax.faces.application.MessageImpl class is the concrete implementation of the Message interface.

The javax.faces.component Package
The javax.faces.component package provides interfaces and classes that represent the standard UI components in JSF. The most notable member of this package is the UIComponent interface, which every UI component must implement. A convenience base class that implements this interface is UIComponentBase. Then there are other classes that represent UI components, such as UIForm, UICommand, UIGraphic, UIInput, UIOutput, UIPanel, and UISelectItem. These components are discussed in Chapters 4 and 5.

The javax.faces.context Package
The javax.faces.context package contains classes and interfaces that define per-request state information. The FacesContext class represents all of the per-request state information that is needed by the Lifecycle object during the request processing lifecycle. A FacesContext contains many other important objects, such as the component tree and the ExternalContext class.

The ExternalContext class, also a member of this package, is there so that JSF does not need to depend on any particular container. Thanks to this class, JSF can run in either a servlet or a portlet. In a servlet environment, you can get information contained in the ServletContext, ServletRequest, and ServletResponse objects through the instance of ExternalContext.

Other important members of this package are FacesContextFactory and MessageResources. FacesContextFactory is responsible for the creation of FacesContext objects. The MessageResources class represents a collection of message templates that help in constructing localized messages. Chapter 11 discusses how you can achieve internationalization and localization of your JSF applications.

Buy this book now!Remember: This is part three of the second chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). If you've enjoyed what you've seen here, click on the "Buy it now!" banner to pick up a copy today!
Buy this book!

>>> More Java & J2EE Articles          >>> More By McGraw-Hill/Osborne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: