February 21, 2019
Hot Topics:

Is Java Server Faces a Bona Fide Panacea for the Web UI?

  • May 11, 2006
  • By Vlad Kofman
  • Send Email »
  • More Articles »

Industry Support

JSF is a specification; therefore, any vendor can write their own implementation and compete on performance and features. Sun has the reference implementation (RI) and Apache has the MyFaces version.

Currently, JSF is well supported by the industry and companies such as Oracle, IBM, and the Apache Software Foundation are actively developing for it. A lot of Java IDEs on the market directly recognize core JSF tags. Here are the screen shots from JBuilder and JDeveloper, but MyEclipse, Exadel Studio pro, IBM WSAD, BEA Workshop, Sun Studio Creator, and a lot of other tools support this technology as well.

JSF components selectors: JDeveloper left, JBuilder right

Using the JSF

For the purposes of this article, I have developed a very simple application that nevertheless demonstrates key concepts of the JSF. It used tags, managed bean, navigation flow, bindings, and fires an event that changes the model state.

I used Borland JBuilder and WebLogic server to test, but any IDE and any server can be used. On the left is the final project structure.

The project retrieves the weather info based on the user's location. There are only two pages, the input (weather.jsp) and exit.jsp. The user selects the location from the select box and then clicks the button; that submits the form (see screen shots at the end).

To set up the framework, I imported the JSF (and JSTL) libraries into the project, (most IDEs do this automatically).

Next, I added the Faces controller servlet to the standard J2EE web.xml descriptor file and indicated that any request to an extension *.f will be handled by this servlet. Actually, any extension can be used. The JSF will correctly call the JSP, and if I wanted to, I could have called the extension .asp to hide the server technology I use.

      <servlet-name>Faces Servlet</servlet-name>
      <servlet-name>Faces Servlet</servlet-name>

I created the managed bean (com.jsf.src.BackingBean) to hold the weather information, and added two empty JSP files. (Some IDEs will create the JSPs, bean classes, and their properties from the faces-config wizard) Next, I visually configured the faces-config.xml file to set up the flow and reference to the backing bean.

Here is the screen shot of JBuilder's Faces Config editor:

The end resulting XML looks like this:


      <description>Navigation for the weather app.</description>

      <description>backing weather bean.</description>

Note: I set a navigation rule on "success" to go to exit.jsp. Also, I set the scope of the bean to "session" and its name to be "weatherBean". The scope for JSF managed beans could be application, session, and request.

Then, it was time to put JSF tags into the JSPs.

Page 2 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date