JSF Tutorial

Intertech Tutorials

Tutorial Objectives:

Java Server Faces (JSF) is a large framework for building user interfaces; particularly Web application user interfaces in HTML. The upcoming chapters are meant to serve as an introduction to JSF and are not an exhaustive exploration of the topic. Resources for more research and education on JSF are provided at the end of these chapters.
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… MVC design separates applications into three general portions. This separation of concerns allows the view and model to be independent of each other. JSF implements the model-view-controller (MVC) architecture. A special JSF “Faces” servlet, special JSF JavaBeans (backing beans) and event listeners serve in the role of controller. Typically (for HTML Web applications), JSF JSP pages with JSF custom tags, associated UI components and the JSF renderer handle the view. JavaBeans provide the basis for the JSF model. More on each of these is discussed later.

Where did JSF come from?

JSF was started by an expert group in May 2001. The co-lead of the JSF expert group was Craig McClanahan. McClanahan was the original author of Apache Struts. He is the architect of the Catalina Tomcat container. He also served on expert groups for servlet and JSP specifications.

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: JSF leverages the capabilities and familiarities of:
What you need to do JSF:

JSF applications are standard Java Web applications. You need an implementation of JSF. Sun provides a reference implementation. JEE 5 SDK contains the JSF 1.2 reference implementation. There are other 3rd party implementations (WebGalileo Faces). There are 3rd party open source JSF implementations (MyFaces, Smile). Most of the major application vendors support/implement JSF (IBM, Oracle, Sun) or support the integration of the reference implementation.

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.