In the Trenches is a new series about real world projects that use JavaServer Faces. This installment looks at how Global Apparel Network BV migrated an existing Struts customer support application to JSF.

If you've completed a JSF project, or you're substantially into a new project, we'd love to hear from you! Send an e-mail to trenches@jsfcentral.com describing your experiences -- the good and the bad -- and we may include your story in a future In the Trenches article.

Senior Developer Dave Sag and his team at Global Apparel Network BV decided to get their feet wet with JavaServer Faces (JSF) by migrating an internal customer support tool from Struts. "We wanted a small and simple, real project to prototype JSF, having worked with Struts for years and built v1.0...with Struts. We migrated from Hibernate to JDO (Java Data Objects) at the same time, so that was interesting too."
Instead of migrating from Struts incrementally using the Struts-Faces integration library, the team chose to migrate the whole application at once. Even though Sag believes there are a few things Struts makes easier, overall he found JSF to be simpler and more robust. The main mental hurdle for the team was thinking in terms of JSF events instead of Struts Actions.

Global Apparel Network BV is also interested in another of JSF's features: the ability to render the UI for different types of devices. Since they develop both Swing and HTML-based applications, they are considering developing either a Swing or XML User Interface Language (XUL)-based client using the same JSF back-end. The company is also considering using the administration screens inside of a portal.

According to Sag, the biggest problem during the migration involved a lack of – or simply old – on-line documentation. Far too often, Google would return out-of-date information containing tags that had been removed prior to the release of JSF 1.0.

Since JSF is still new, the other main problem was dealing with bugs in current JSF implementations. Version 1.0 of the reference implementation (RI) had several bugs, but when the team switched to version 1.1 of the RI, they encountered a bug that prevented some of their components from working properly. Fortunately, the availability of the MyFaces open source implementation came in handy for Global Apparel Network BV. During the project, the team constantly switched between the RI and MyFaces.

Sag was particularly happy with the response of the JSF RI team. Since Sag used the RI bug trackers on java.net, Sun's team "got patches ready within days. Now they are debating the finer points of the spec that are affected by the patch, but I got my fix." Global Apparel Network BV intends to stick with the RI for now.

This underscores one of the key benefits of Java standards – choice. Sag and his team were able to switch back and forth easily between JSF implementations with minimal effort, and will continue to do so when necessary.
As the project progressed, the team realized that their users needed to manage a large amount of static content. Instead of building their own content management system from scratch, they chose Magnolia, which is a well-established Content Repository for Java (JCR)-compliant open source project from obinary. Rather than integrate Magnolia with JSF components, they chose to use Magnolia's existing template engine in conjunction with JSF-based administration functionality. "Magnolia is better when your content is king. JSF is better when you have some real work to do at the back end and are not just displaying content," comments Sag. Since JSF pages can easily co-exist with non-JSF pages inside of the same web application, integrating Magnolia was not a difficult task.

Global Apparel Network BV used a diverse set of software and operating systems in the development of their JSF customer support application including Eclipse, JBuilder, BBEdit, Ant, and CVS on a combination of MacOS, Windows, and Linux. They tested the application locally using Tomcat 5 and MySQL and their production environment uses Tomcat 5 and Microsoft SQL Server.

Currently, the newly-developed JSF application is in QA. According to Sag, "Our prototyping has been a success... and our new JSF web [application] does lots more and simpler." Now that this project has been completed, Sag believes they have a solid platform for the future. This includes Magnolia for content management, Apache Jackrabbit for accessing the JCR-compliant content repository, custom JSF content display components, JDO for non-JCR data in legacy systems, Java Authentication and Authorization Service (JAAS) for security, and Tomcat 5. "We have quite a few projects to roll out this year and are pretty confident we have our framework right," Sag declares.

Kito D. Mann is editor-in-chief of JSFCentral and the author of JavaServer Faces in Action (Manning). He is also a member of the JSF 1.2 and JSP 2.1 expert groups, and a consultant specializing in enterprise application architecture, development, mentoring, and JSF product strategy. He can be reached at kmann@jsfcentral.com.

Copyright (C) 2003-2015 Virtua, Inc. All Rights Reserved. Java, JavaServer Faces, and all
Java-based marks are trademarks or registered trademarks of Oracle Corporation. in the
United States and other countries. Virtua, Inc. is independent of Oracle Corporation. All other trademarks are the sole property of their respective owners.