Java Reference
In-Depth Information
33.1 Introduction
JavaServer Faces (JSF) is a new technology for developing server-side Web
applications using Java.
Key
Point
JSF enables you to completely separate Java code from HTML. You can quickly build Web
applications by assembling reusable UI components in a page, connecting these components
to Java programs and wiring client-generated events to server-side event handlers. The appli-
cation developed using JSF is easy to debug and maintain.
JSF
Note
This chapter introduces JSF 2.2, the latest standard for JavaServer Faces. You need to
know XHTML (eXtensible HyperText Markup Language) and CSS (Cascading Style
Sheet) to start this chapter. For information on XHTML and CSS, see Supplements V.A
and V.B on the Companion Website.
JSF 2.2
XHTML
CSS
Caution
The examples and exercises in this chapter were tested using NetBeans 7.4, GlassFish 4,
JSF2.2, and J2EE 7. You need to use NetBeans 7.4 or a higher version with GlassFish 4,
JSF 2.2, and J2EE to develop your JSF projects.
NetBeans 7.4
GlassFish 4
J2EE 7
33.2 Getting Started with JSF
NetBeans is an effective tool for developing JSF applications.
Key
Point
We begin with a simple example that illustrates the basics of developing JSF projects using
NetBeans. The example is to display the date and time on the server, as shown in Figure 33.1.
F IGURE 33.1
The application displays the date and time on the server.
33.2.1 Creating a JSF Project
Here are the steps to create the application.
Step 1: Choose File , New Project to display the New Project dialog box. In this box,
choose Java Web in the Categories pane and Web Application in the Projects pane. Click
Next to display the New Web Application dialog box.
create a project
In the New Web Application dialog box, enter and select the following fields, as shown
in Figure 33.2a:
Project Name: jsf2demo
Project Location: c:\book
Step 2: Click Next to display the dialog box for choosing servers and settings. Select
the following fields as shown in Figure 33.2b. (Note: You can use any server such as
GlassFish 4.x that supports Java EE 7.)
Server: GlassFish 4
Java EE Version: Java EE 7 Web
choose server and J2EE 7
 
 
 
 
Search WWH ::




Custom Search