Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
Add note
Save to My Library
Sync to mobile
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
JavaServer Faces (JSF) Tutorial

JavaServer Faces (JSF) Tutorial



|Views: 4,693|Likes:
Published by api-25930603

More info:

Published by: api-25930603 on Oct 16, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, DOC, TXT or read online from Scribd
See More
See less





JavaServer Faces (JSF) TutorialJSF KickStart: A Simple JavaServerFaces Application
In this tutorial, we will show you an example of a JSF application developed without anyspecial IDE. We won't dwell on the theory behind JSF here. There are plenty of sites and books that will do that for you. Instead, we will go quickly into the construction of thissimple application that we hope can form the basis for you to start developing moreadvanced applications.
What Is JavaServer Faces?
Per our promise, we will keep the background simple. JavaServer Faces is a newframework for building Web applications using Java. JavaServer Faces provides you withthe following main features:
Page navigation specification
Standard user interface components like input fields, buttons, and links
User input validation
Easy error handling
Java bean management
Event handling
Internationalization supportJSF provides the common plumbing for any Web application allowing you to concentrateon your specific application (instead of worrying about things like how to create a link from one page to another). This will become clearer as we go along.
What Will You Need?
You will need the following to complete this tutorial:
JDK 1.4
Tomcat 5.0 or any other servlet container (JBoss, Resin, JRun). We will useTomcat in this example.
AntWe will provide you with many of the project files so that you don't need to create themyourself. We will be concentrating primarily on the actual JSF application, not oncreating Ant scripts or web.xml files. These files will be provided for you. You will justneed to copy and paste content from this tutorial.
What Are We Going to Build?
You may have guessed by now. We are going to build a "Hello, world" (actually"Welcome to JSF, <user>!") type application using JSF. This should give you a solid startwith JSF.We will create two pages. The first page will prompt a user to enter his or her name andthe second page will show a greeting. This is a sample of the input page:and this is a sample of the result page:
JSF Application Structure
We have provided you with a pre-made project structure skeleton in an archive called
that you candownloadand unzip. After unzipping you should have thefollowing structure:
This is a typical skeleton structure for a Web application like JSF. Now, let's go throughthe different parts of the skeleton structure.
folder or file explanation
 jsfksProject folder with project name/antThis folder holds Ant build scripts including a default
file./JavaSourceThis folder is where you place your own Java source classes and properties files./WebContentThis folder holds the actual Web application files used by the applicationserver or servlet container./WEB-INFThis folder inside the
folder holds files that are used as part
of the runtime Web application but are hidden from the browser./classesThis folder inside the
folder holds compiled Java classesalong with properties files copied from
./libThis folder inside the
folder holds libraries required by your application, for example, third party Jar files.jsf-impl.jar jsf-api.jar These two files inside the
folder are library files included with theJavaServer Faces v1.1 Reference Implementation. Every JSF applicationrequires these files.web.xmlThis file inside the
folder is the Web Application DeploymentDescriptor for your application. This is an XML file describing theservlets and other components that make up your application.faces-config.xmlThis file inside the
folder is the JavaServer Facesconfiguration file. This file lists bean resources and navigation rules. Wewill cover this file in more detail later. pagesThis folder inside the
folder holds JSP and HTML presentation pages.We have already provided you with two complete project files in the the project,
, so that you don't have to spend time creating these. (Thistutorial is not about creating these kinds of files.)
The Steps
We will complete the following steps:1.Create JSP pages2.Define a navigation rule3.Create a managed bean4.Create a properties file5.Edit JSP pages6.Create an index.jsp file7.Compile the application8.Deploy and run the applicationLet's get started.
Downloadable Version of Finished Project
But first note that we have also provided you with the finished application in case you just want to just run it and skip most of the steps. If you want to do this, you candownloadand unzip
. Then skip to the"compile" stepand go from there.
Creating JSP Pages

Activity (13)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Ankit Jain liked this
Abhijeet Sutar liked this
gashwani liked this
kanna1620 liked this
manwe7777 liked this
smrsaxena liked this
luis20010 liked this
luis20010 liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->