When Prisma, an Austrian credit insurance company, wanted to replace the Java applet running their on-line customer service system, they chose Java consulting firm Irian to build a new application using JavaServer Faces (JSF). The two principals of Irian, Martin Marinschek and Thomas Spiegl, know JSF well - both are members of the development team of the Apache MyFaces open source JSF implementation.
Spiegl is one of the co-founders of MyFaces, which he began developing with Manfred Geiler in 2003 on SourceForge. This came about because Spiegl and Geiler were interested in developing web applications with a Java Community Process-sanctioned standard web framework, but were unhappy with the level of maturity of the reference implementation at that time. Since then, MyFaces has grown in popularity and has recently joined the Apache Software Foundation.
The team has several years of experience in building web applications, beginning with C++. Like many developers, they once had their own home-grown web application framework. "We are sure that JSF saved us loads of time in comparison with just programming JSPs and servlets. Additionally, we are sure that maintenance is much easier with this standardized framework and the open-sourced components," comments Marinschek.
During approximately five months of part-time work on the project, Marinschek and Spiegl, as well as one developer at Prisma, built Prisma.Net. Prisma.Net serves as a hub for about 2,000 clients, managing their accounts and allowing them to track payments and claims, examine contractual terms, and perform other account management duties (see figure 1).
Figure 1. Prisma.Net uses JSF components to provide an intuitive, powerful user interface.
In addition to the MyFaces JSF runtime and custom components, Irian used other Apache projects including POI for manipulating Microsoft Excel files, and the Commons libraries for additional plumbing.
Marinschek and Spiegl developed the application using Windows 2000 with JetBrains IntelliJ and Apache Ant. The deployment platform includes RedHat Linux Enterprise Server 3, JBoss, and Tomcat.
Under the Hood
The back-end of Prisma.Net uses stateless session beans developed in-house by Prisma. The session beans communicate with the company's AS400 system, which houses the core business logic and database. The web front-end communicates with the session bean through a business delegate that is also responsible for creating transfer objects.
The view layer was developed by Irian using JSPs with JSF tag libraries, but do not contain any logic or JSTL tags. Page composition was achieved with Tiles, using MyFaces' built-in Tiles support.
Each JSF view is represented by a model class, which references a composite entity containing the business data necessary for displaying the view. The model retrieves this data through the business delegate, and also manages additional information necessary for rendering the view.
Each view also has a controller that is responsible for storing or deleting the data. Unlike the model classes, controller classes directly access JSF APIs. Irian separated the model and controller as much as possible, especially for code that might be reused in another context, such as a Swing application.
To enable this separation, the team developed a GUIContext class, which is used as a wrapper around the standard FacesContext class. There is also a GUIContextFactory class, which is responsible for creating and caching the GUIContext for each request.
The GUIContext also maintains a reference to a SessionData instance, which contains information such as the user's name, which is displayed on every page. SessionData state can be stored either on the client or on the server. When an instance of the object is stored on the client, Prisma.Net takes advantage of MyFaces' SaveState component (see figure 2 for a class diagram of the system).
Figure 2. Prisma.Net class diagram.
A Successful Facelift
"So far, the user feedback has been very good, and the usability has been improved in comparison to the [usability] of the applet that existed before," comments Spiegl. Irian is currently putting the final touches on Prisma.Net, and intends to use JSF as the foundation for future projects.