adam bien's blog

To JSF Or Not To JSF ...This Is The Question - or Why vi is Not Enough 📎

  1. Java Server Faces 1.2 are already shipped with every Java EE 5 server - so before you are choosing a more esotheric framework, you should at least evaluate JSF.
  2. JSF are component based - the development model is event-driven and similar to Swing
    1. A backend object (backing bean) receives the events (just a method)
    2. Bi-directional, declarative Data Binding can be used to synchronize the view-components with the backing bean
    3. The backing bean runs on the server - it can access e.g. the EJB 3.0 per Reference. "Fat Client" programming model is possible :-). This is a huge advantage. No value objects, client objects etc. are required.
    4. Model View Presenter / Model View Controller patterns are easy to implement. The presenters / controllers can be even shared with Swing apps (in theory - in practice the views are too different).
  3. Convenient data conversion for the common types (e.g. from String to int) already happens behind the scenes.
  4. Validation support is already built in.
  5. Navigation / Page Flow are provided and standardized.
  6. Visual tool support for JSF is outstanding. Most of the tools are free e.g. Netbeans 6.1, Oracle JDeveloper, Eclipse with Plugins (e.g. Visual Page Designer in WTP 2.0). Some tools (e.g. Netbeans) provide visual support for page flows.
  7. There are already many JSF component providers - many have AJAX support, and are opensource.

JSF programming with good tool support can be very productive (in my opinion - unbeatable). So it is absolutely possible to build from scratch a CRUD app in three minutes (with nice table - sorting included) - without hacking. In case a given JSF provider fully covers your customer's requirements - it's the best choice. Some extensions like Shale or Tiles, help you better structuring your application / page flow. However I would only use them if necessary (every jar increases the complexity...- and makes the deployment harder).

Nevertheless JSF 1.2 has also a "dark side":

  1. The amount of XML-configuration is considerable (therefore tools are absolutely needed - vi, even emacs are not enough :-))
  2. Building custom components requires some deeper knowledge - it is not so simple, as it could be.
  3. Every request is a POST request - you will need some workarounds for bookmarking etc.
  4. For more sophisticated applications - you will need to understand the "6 phases" - this can take a day of experimentation to fully understand it.
  5. You will still need JavaScript / AJAX expertise, regardless how good your framework is.
  6. Customizing the look and feel of the visual components, can be time-consuming. Go with the default if possible.
  7. The whole component tree is cached on the server in memory - you should plan some performance tests to verify the requirements. In general the performance is o.k.
So to JSF Or Not To JSF - I'm a consultant - so the answer is clear: "it depends" :-). If you are building a corporate, enterprise application - JSF are just perfect. On the other hand, if you target is the consumer market, you are probably looking for more flexibility (and probably more effort to build the app then). Already looking forward to JSF 2.0 :-).