About this tutorial
This tutorial explains and demonstrates the use of JavaServer Faces (JSF) technology to develop XForms applications. The JSF API (JSR-127) allows enterprise Java™ developers to build user interfaces for their server-side applications. XForms (a W3C recommendation) is an XML application that provides a framework for designing XML-based data entry forms.
This tutorial covers XForms authoring requirements in a server-side Java application. It provides the inside-out picture of the JSF technology and shows how XForms authoring requirements fit into the JSF architecture. It also lists the tasks required if developers are going to use JSF technology for XForms authoring and demonstrates the development of a JSF tag library capable of authoring XForms markup.
We will also develop a sample application (XForms-JSF shopping cart) so you can see the concepts put to work in a real-world application.
JSF technology provides the API for authoring user interfaces, and XForms defines the markup that needs to be produced. Therefore, it is natural to expect that many Java application developers will need to author XForms markup using the JSF API. That's why we have chosen XForms as our sample application in this tutorial. However, the concepts presented are applicable to all types of JSF applications, so we've provided sample code to help answer your JSF technology questions.
To take this tutorial, you should be a Java programmer with some knowledge of JavaBeans and the JavaServer Pages (JSP) technologies. This knowledge is necessary to understand most of the coding details and examples. You also need to be familiar with XML.
This tutorial will help you:
- Understand the JSF architecture
- Know how the JSF framework internally works
- Know what is happening inside a JSF application
- Comprehend the different phases of a JSF application
- Develop your own JSF tag library
This tutorial is not for readers who simply want to use the existing JSF core and HTML tag libraries. If you'd like to learn more about the existing JSF tag libraries, there are some excellent resources available on developerWorks, as detailed in Resources.
This tutorial is divided into the following sections:
- Section 1 is the introduction and overview.
- Section 2 covers the XForms authoring requirements in server-side
Java applications. To cover the authoring requirements, we'll use a
shopping cart application scenario, and present the flow of data and
user interactions in an XForms application. then
we provide a list of requirements to fulfill if you are to
use XForms in a server-side Java application.
- Section 3 offers a high-level view of the JSF architecture. This
section lists the components required to build a JSF application. It
covers many of the core JSF technology concepts without going into the low-level
details of each concept.
- Section 4 provides low-level details of JSF technology concepts.
- Section 5 discusses the two important components you will
build in almost all your JSF applications: model beans and event handlers.
This section demonstrates the development of model beans to hold
application data and event handlers to handle JSF events. By the end of
Section 5, you should have enough knowledge about JSF technology to start building your
own JSF tag libraries.
- Section 6 demonstrates how you can use JSF technology to fulfill the
server-side requirements of XForms applications. This section will also present
the strategy for XForms-JSF technology integration and demonstrate this strategy
by developing three XForms-JSF components.
- Section 7 walks you through the development of many more XForms-JSF
components using the concepts we learned in Section 6. At the end of
this section, we will demonstrate how to build Java Archive (JAR)
files to distribute your own tag libraries.
- Finally, in sections 8 and 9, you'll put your JSF and XForms technology knowledge to the test by building a comprehensive real-world application.
To run the sample applications, you will need the following:
- J2SE V1.4.2
- J2EE V1.4.0 Update 1
- An application server
- An XForms browser
I tested the sample applications using J2SE V1.4.2, J2EE V1.4 (Update 1), Sun Java System Application Server Platform Edition V8, and Forms Player V1.0 (XForms browser) on Microsoft® Windows® 2000 Professional Edition Service Pack 2. You should be able to use any J2EE 1.4-compliant application server.
The sample applications are available in the source code download for this tutorial. This download contains three zip files: section6.zip, section7.zip, and section9.zip (see Resources). These files contain code for the sample applications developed in their respective sections. The steps to try the sample applications in an individual zip file are discussed in their relevant sections.