Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

A first look at JavaServer Faces, Part 1

Learn how to implement Web-based user interfaces with JSF

  • Print
  • Feedback

Recently, I had the good fortune of training and mentoring a group of novice Java developers as we implemented a complex Web application using Struts, Enterprise JavaBeans (EJB), servlets, JavaServer Pages (JSP), and the JSP Standard Tag Library (JSTL). As it turned out, the project was a success; it came in under budget and on time, and had numerous features not originally envisioned. As you might imagine, we faced many technical challenges along the way; the most significant were:

  1. Implementing custom components, which included a tree/table viewer and a query builder that lets users dynamically add and remove fundamental components such as text fields and drop-down lists used to build database queries.
  2. Supporting hand-held devices, such as PDAs and radio frequency devices.
  3. Lack of an IDE for effective rapid application development (RAD).


Implementing custom components and supporting hand-held devices—especially the latter—consumed a great deal of our time and effort. Also, although some of the developers used the Eclipse open source IDE, we lacked an effective RAD tool for implementing the Web application's user interface.

Unless you've been living in a cave for the past few years, I'm sure you're aware that tools exist for creating custom Web components and supporting markup languages other than HTML, all of which are wrapped up in a very nice IDE. That software, of course, is Microsoft's .Net with WebForms; the IDE is Visual Studio.

In spite of those attractive .Net features, the company I was working for—like many software development companies nowadays—opted to go with the Java 2 Platform, Enterprise Edition (J2EE) because of its platform and vendor independence and the wealth of available open source software for Java and J2EE.

Wouldn't it be nice if you could take advantage of Java and .Net's best features, platform and vendor independence, open source products such as Ant and log4j, and the ability to easily create custom Web components and render them to multiple devices, all wrapped up in a killer IDE? That's the promise of JavaServer Faces.

Read the whole series, "A First Look at JavaServer Faces:"



Note: You can download this article's source code from Resources.

What is JavaServer Faces?

JavaServer Faces (JSF) is an application framework for creating Web-based user interfaces. If you are familiar with Struts (a popular open source JSP-based Web application framework) and Swing (the standard Java user interface framework for desktop applications), think of JavaServer Faces as a combination of those two frameworks. Like Struts, JSF provides Web application lifecycle management through a controller servlet; and like Swing, JSF provides a rich component model complete with event handling and component rendering.

In a nutshell, JSF eases Web-based application development because it:

  • Lets you create user interfaces from a set of standard, reusable server-side components
  • Provides a set of JSP tags to access those components
  • Transparently saves state information and repopulates forms when they redisplay
  • Provides a framework for implementing custom components
  • Encapsulates event handling and component rendering so you can use standard JSF components or custom components to support markup languages other than HTML
  • Lets tool vendors develop IDEs for a standard Web application framework


Besides being a conceptual combination of Struts and Swing, JSF is a direct competitor to Microsoft's WebForms. The frameworks are very similar, both in concept and implementation. And because JSF represents a standard for Java-based Web application frameworks, tool vendors can concentrate on developing IDEs for JSF instead of developing an IDE for one of approximately 35 existing Java-based Web application frameworks, including Struts.

  • Print
  • Feedback

Resources