Chapter 9. JavaServer Faces and Ajax

JavaServer Faces (JSF) is a user interface framework that runs on a Java application server and renders a user interface to a client. The most popular client is a web browser running on a desktop computer, but JSF is not limited to web applications. Although it is a complex technology—learning JSF isn’t a trivial task—once you’ve learned it, you will be able to build many web applications faster. If you are unfamiliar with JSF, you can learn it by reading the JavaServer Faces Specification, Sun’s tutorial (http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFIntro.html), or one of the reference books written on the subject. Hans Bergsten, one of the spec’s contributors, has written an excellent introduction and reference called JavaServer Faces (O’Reilly). I learned JavaServer Faces using that book and Sun’s JSF tutorial (which is actually part of the J2EE tutorial) as my primary tools.

JavaServer Faces provides a clean separation between the business logic and presentation layers. It establishes a one-to-one mapping between HTTP requests and components. This mapping allows a finer-grained model for a web application than a typical JSP application can provide. With JSF, there is a lifecycle for communication between the web page and the Java beans that makes up the backend. There are listeners that listen for events and renderers that create a view for display to the user. Writing a JSF application is not unlike writing a Swing application—and it’s ...

Get Ajax on Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.