Java Reference
In-Depth Information
Introduction to JavaServer Faces
Before JSF was developed, Java web applications were typically developed using
non-standard web application frameworks such as Apache Struts, Tapestry, Spring
Web MVC, or many others. These frameworks are built on top of the Servlet and JSP
standards, and automate a lot of functionality that needs to be manually coded when
using these APIs directly.
Having a wide variety of web application frameworks available (at the time of
writing, Wikipedia lists 35 Java web application frameworks, and this list is far from
extensive!), often resulted in "analysis paralysis", that is, developers often spend an
inordinate amount of time evaluating frameworks for their applications.
The introduction of JSF to the Java EE 5 specification resulted in having a standard
web application framework available in any Java EE 5 compliant application server.
We don't mean to imply that other web application frameworks
are obsolete or that they shouldn't be used at all, however, a lot of
organizations consider JSF the "safe" choice since it is part of the standard
and should be well supported for the foreseeable future. Additionally,
NetBeans offers excellent JSF support, making JSF a very attractive choice.
Strictly speaking, JSF is not a web application framework as such, but a component
framework. In theory, JSF can be used to write applications that are not web-based,
however, in practice JSF is almost always used for this purpose.
In addition to being the standard Java EE 5 component framework, one benefit of
JSF is that it was designed with graphical tools in mind, making it easy for tools
and IDEs such as NetBeans to take advantage of the JSF component model with
drag-and-drop support for components. NetBeans provides a Visual Web JSF
Designer that allow us to visually create JSF applications. This tool is discussed in
detail in Chapter 6.
Developing Our first JSF Application
From an application developer's point of view, a JSF application consists of a series
of JSP pages containing custom JSF tags, one or more
JSF
managed
beans
, and a
configuration file named
faces-config.xml
. The
faces-config.xml
file declares
the managed beans in the application, as well as the navigation rules to follow when
navigating from one JSF page to another.