18.1 Struts and JavaServer Faces


You might be wondering, "What does JavaServer Faces have to do with Jakarta Struts?" The truth is, quite a bit. First and foremost, Craig McClanahan has a hand in both. As mentioned several times already, he is the creator of Struts and still participates as its steward, but he is also one of the technical leads on the JavaServer Faces JSR-127, along with Ed Burns. However, the key similarity between JSF is that both attempt to solve the same problem. That is, they are both Java frameworks for building web-based applications, with one big exception JSF is an actual specification, along the lines of JDBC, JNDI, EJB and so forth. Like other Java specifications, Sun and the JSR committee provide a set of APIs that describe the contract between a client and a provider of the technology. With JSF, the actual implementation of the JSF specification is left to the vendor to implement.

In many specifications, a reference implementation is provided with the API to help ensure adherence to the specification and compatibility between providers.


In contrast to JSF, Struts is based on a proprietary framework and API. Actions and forms built for use within a Struts application must be modified (or even rewritten) when switching to a different framework. There's also only one provider of Struts:Apache and the Struts development community. With JSF, there will be multiple implementations.

JSF's goal is to provide a way to build UIs (buttons, checkboxes and other widgets) that are client-independent. It does this by utilizing a rendering kit that contains client-dependent parts of the UI. The rendering kit detects the client in use and renders the widgets appropriately. JSF also supports the ability to create custom widgets, much like Java Swing. In fact, you can build completely new rendering kits if there are none available for your client type.

18.1.1 Do We Really Need Another UI Framework?

An often asked and completely valid question is: "Do we really need a new UI framework?" In fact, many would argue that we have too many already! These questions do need to be asked, but one must keep an open mind when asking them. Contrary to how one group or another might try to market a framework (commercial or open source), no single framework can contain every feature that every application might demand; this holds true for all types of frameworks. The more important question is: "Does JSF bring anything new to the mix?"

18.1.2 The Big-Picture Benefits of JSF

JSF does include several features currently found in existing UI frameworks. However, along with these features, it also includes things that can't be obtained from a single framework. Let's spell out several niceties of JSF and why you might consider using it by itself or in conjunction with the Struts framework.

The goal of JSF is to provide reusable server components for creating user interfaces. As such, it provides the following benefits for Java developers:

  • An extensible UI component model

  • An event handling model

  • A pluggable rendering model

  • A presentation validation framework (for both client and server side validation)

  • A simple page navigational model

  • Internationalization (I18N) support

  • Integrated support for accessibility

These benefits alone make JSF as powerful, if not more so, than many of the UI frameworks available today. Add to that a standardization which guarantees that multiple vendors will provide implementations, and JSF starts to become a very attractive option.



Programming Jakarta Struts
Programming Jakarta Struts, 2nd Edition
ISBN: 0596006519
EAN: 2147483647
Year: 2003
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net