JSF 1.x Tutorial

An Introduction to JavaServer Faces 1.x with Apache MyFaces Extensions

Interested in live training from the author of these tutorials? See the upcoming JSF 2 and PrimeFaces training courses in Maryland, co-sponsored by Johns Hopkins. Or, contact hall@coreservlets.com for info on customized JSF 2 or PrimeFaces courses onsite at your location. See the JSF training page for various options for the onsite courses.


This tutorial covers JSF 1.x with Apache MyFaces, but the the JSF 2.0 tutorial covers JSF 2 with the free Mojarra JSF2 implementation. The JSF 1 tutorial is left online only for those maintaining existing projects: JSF 2 is both simpler and more powerful than JSF 1, and is strongly preferred for all new projects. Click on a topic below to get the detailed tutorial, download the source code, or try out exercises on the topic.

This tutorial is derived from Marty Hall's world-renowned live JSF training courses. Courses on JSF 1.x or 2.0 are usually taught on-site at customer locations, but Java 7, servlet, JSP, Ajax (with jQuery), GWT, Spring, Hibernate, Web Services (SOAP and REST), Hadoop, JSF 1.x, JSF 2.0, and PrimeFaces training courses at public venues are periodically scheduled for people with too few developers for an onsite course. For descriptions of the various other courses that are available, please see the Java EE and Ajax training course page. To inquire about a customized training course at your location, please contact Marty at hall@coreservlets.com.

If you find these free tutorials helpful, we would appreciate it if you would link to us. Send corrections or feedback on any tutorial to hall@coreservlets.com.

Servlets and JSP: A Review of the Basics

This section provides a quick review of the basics of servlets and JSP, as a review before moving on to the JSF-specific topics. Please note that this section is not detailed enough for those who have never done server-side programming in Java; it is intended as a review for those who have done it before, but are rusty. If you are new to building Web apps in Java, please see the beginning and intermediate servlet and JSP tutorials.

Introducing JSF

  • This tutorial section in PDF.
  • jsf-blank-myfaces.zip
    Blank Web app to use as a starting point for JSF applications. Apache MyFaces version, bundled as an Eclipse project. Has all necessary JAR files in WEB-INF/lib, all required settings in WEB-INF/web.xml, a a blank WEB-INF/faces-config.xml file, and the JSF project facet for Eclipse.
  • Exercises to reinforce the concepts in this section.
  • Topics covered:
    • Understanding JSF
      • Different views of JSF
      • Comparing JSF to standard servlet/JSP technology (Pros/Cons)
      • Comparing JSF to Apache Struts (Pros/Cons)
    • Setting Up JSF
      • Downloading and configuring JSF
        • Apache MyFaces
        • Sun Reference Implementation
      • Testing JSF
      • Setting up JSF applications
      • Accessing JSF documentation
        • Generic
        • Specific to Apache MyFaces

Controlling Page Navigation

Handling Request Parameters with Managed Beans

Using the JSF Expression Language

Using Properties Files (Resource Bundles)

Handling Events

Building Input Forms with the h: Library

Validating User Input and Redisplaying Incomplete Forms

Accessing Databases with JDBC

Displaying JSF Data Tables

Using the Apache MyFaces Components (Tomahawk)

Using the Ajax4jsf Library

Creating Custom JSP Tag Libraries: The Basics

Creating Custom JSP Tag Libraries: Advanced Topics

Developing Custom Components

Page Templating with Facelets

Using (Struts) Tiles with JSF

Now that Facelets are well established, Tiles is considered obsolete by many JSF developers. So, unless you have a specific reason to use Tiles, look at the previous section on Facelets instead of this section.

The JSP Standard Tag Library (JSTL)

JSF References

Source Code

Source code for all examples in this tutorial can be downloaded from the JSF 1 sample code repository. Each section also has links to the code used in that section.

PowerPoint Files for University Faculty

The PDF files in this tutorial contain the complete text of the original PowerPoint files, so if your goal is learning this technology, just stick with this tutorial. However, as a service to instructors teaching full-semester courses at accredited universities, coreservlets.com will release the original PowerPoint files for free. Please see the instructor materials page for details.

More Information

Java

JSF (JavaServer Faces)

Servlets & JSP
Ajax, GWT, & JavaScript

Spring, Hibernate, & JPA

Struts