The Artima Developer Community
Sponsored Link

Java Community News
What Spring Web Flow Offers JSF Developers

1 reply on 1 page. Most recent reply: Apr 24, 2007 9:31 AM by Ivan Lazarte

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

What Spring Web Flow Offers JSF Developers Posted: Apr 23, 2007 3:18 PM
Reply to this message Reply
Summary
Linking pages together in the context of JSF's stateful programming model has proven challenging to many developers. Interface21's Keith Donald penned a short article on how Spring Web Flow can make complex page links and navigation more manageable.
Advertisement

JSF has become a popular framework for stateful Web applications, not the least because JSF is an officially blessed JCP standard with at least two implementations: Sun's reference implementation and Apache's MyFaces.

Defining page navigation is among the most common tasks JSF developers must perform. According to the JSF specs, page navigation describes rules and actions that are taken when a user clicks on a button or a URL link. Most JSF applications define navigation rules in a faces.xml file (examples of JSF navigation rules are presented in the Navigation chapter of Sun's JSF tutorial).

Some developers have noted the challenges associated with JSF's navigation model. Ignacio Coloma, for instance, bemoaned the difficulty of managing navigation in the context of JSF's stateful model:

Then the hell of linking pages together starts.... Faces saves the view state between requests, which is dumb if you are working with persistent data. If you dare to use Hibernate, expect all kind of funny behaviour as a request tries to initialize some lazy relationship of a bean retrieved like two clicks ago. If you must refresh data with each request where is the fun of using a stateful view? Remember that it cannot be disabled easily...

According to an article by Interface21's Keith Donald, What Spring Web Flow Offers JSF Developers, Spring Web Flow can make navigation a lot easier task to implement for JSF applications. Donald is a lead developer of Spring Web Flow:

When used as a JSF extension, Spring Web Flow takes over two responsibilities: handling your view navigation rules and managing the state associated with your ongoing user interactions (a.k.a conversations).

This integration combines Web Flow's strengths in navigation and state management with JSF's strength as a growing ecosystem of user interface component libraries. All JSF components and views continue to work as before with Web Flow in the picture. With Web Flow in there, JSF developers benefit from a considerably more powerful navigation model that alleviates the headaches traditionally associated with managing conversational state manually.

Donald further explains that,

The unit of controller functionality in Spring Web Flow—something like an Account registration wizard or a Customer Master/Detail Editor—is called a flow definition. A runtime instance of such a controller is called a flow execution. A new flow execution is launched at runtime to allow a single user to participate in a dialog with the application. The flow execution handles selecting the user's initial view, then responds to user events to carry out application behaviors and determine the next views to display. It also manages the state associated with the user dialog...

A big part of integrating Web Flow with JSF was fitting its flow execution lifecycle into the JSF lifecycle. This was achieved in part by implementing a custom PhaseListener that handles launching new flow executions when requested by a clients, as well as restoring existing flow executions during the restoration of JSF views.

Once integrated with a JSF application, Donald points out how Spring Web Flow can provide several navigation features that would be more difficult to code up with just plain JSF:

  • The ability to implement dynamic navigation rules that are changeable on-the-fly without a server restart
  • Full forward, backward, refresh, redirect, and recursive navigation capabilities built into its flow definition language
  • Modularization and encapsulation of navigation logic through the flow definition concept... Web Flow can be used as a complete replacement for JSF's default "forward-centric" navigation mode

Donald also notes that work is already under way on Spring Web Flow 1.1:

Greater levels of integration is a major theme in an exciting roadmap. Notable on the JSF front, we will be adding support for the Unified Expression Language (EL) within flow definitions, as well as support for leveraging Spring 2.0 as a comprehensive provider of JSF managed-beans beans across all scopes—including the conversational scopes provided by Spring Web Flow...

What are your favorite frameworks or techniques to implement navigation in a Web application?


Ivan Lazarte

Posts: 91
Nickname: ilazarte
Registered: Mar, 2006

Re: What Spring Web Flow Offers JSF Developers Posted: Apr 24, 2007 9:31 AM
Reply to this message Reply
Webflow is so easy and sensible to use, I think something like it should be available for all web frameworks. The thought of not using it for navigational items is somewhat horrifying. Homegrown navigation systems grow to the point of terror, whereas Webflow and Spring stay clean concise scale easily with regard to complexity in paths.

A user path is something I used to dread working with - even in a scripting app hacking together pages was always one of those things I started the push-back early and would be days. Now I offer more features without thinking about it twice and can implement it in a few minutes...

Spring/SWF has a learning curve but man does it pay off bigtime.

Flat View: This topic has 1 reply on 1 page
Topic: Google Patches, Enhances MySQL Previous Topic   Next Topic Topic: Exposing Persistent Entities as REST Resources

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use