Visit our blog

News & Events

Spring Web Flow 1.0 EA Released

Dear Spring Community,

We are pleased to announce that Spring Web Flow (SWF) 1.0 EA (Early Access) has been released.  Download it.

This release is the proposal to the community for what will become Spring Web Flow 1.0 final.  The release is considered feature complete for the SWF 1.0 roadmap.

With this release we begin a four week evaluation period at the end of which 1.0 RC1 will be released, followed by 1.0 final.   This EA evaluation period is capped at four (4) weeks; its purpose is to allow a final period of feedback to help further ensure the highest quality product possible before we fully lock down the API at 1.0 RC1.

We very much value your feedback at this time, as there are a substantial number of new features available in the product with this release to take advantage of.  The new and noteworthy include...

NEW AND NOTEWORTHY

Support for binding directly to backing business services from a flow definition.  This eliminates the need to code custom Action adapter classes in many cases.  What you are left with is what matters: your flow definition and your service-layer.  In most cases you don’t depend on SWF APIs at all.  Example:

    <action-state id="executeSearch">
        <action bean="phonebook" method="search(${flowScope.searchCriteria})" resultName="results"/>
        <transition on="success" to="displayResults"/>
    </action-state>

    Binds to:

    public interface Phonebook {
        Collection search(SearchCriteria criteria);
    }

    <decision-state id="shippingRequired">
        <action bean="shippingService" method="isShippingRequired(${flowScope.order})"/>
        <transition on="yes" to="enterShippingDetails"/>
        <transition on="no" to="placeOrder"/>
    </decision-state>

    Binds to:

    public interface ShippingService {
        public boolean isShippingRequired(Order order);
    }

Support for four (4) distinct flow response types out-of-the box.  From a ViewState or an EndState it is now possible to request:

  • Direct rendering of an application view (such as a JSP template):

        <view-state id="enterCriteria" view="searchCriteria">
             ...
        </view-state> 

  • A redirect to an application view (such as a JSP template) at a refreshable, well defined conversation URL:

        <view-state id="enterCriteria" view="redirect:searchCriteria">
             ...
        </view-state>

  •  A redirect that starts a new, independent flow from the current flow:

        <end-state id="finish" view="flowRedirect:search-flow"/>

  • A redirect to an external URL:

        <end-state id="finish" view="externalRedirect:/someExternalSystem.htm?${flowScope.input}"/>

What is interesting about this is the above are logical response types.  The actual response issued may vary based on the environment in which the flow is executing (Servlet vs. Portlet, for example)—because of this separation, these environmental differences do not affect your flow definition in any way (making the flow definitions simpler and reusable across environments).

 

Multiple strategies for launching flows and accessing/refreshing/bookmarking ongoing conversations.  This includes:

  • Parameter-based:

http://localhost/swf-phonebook/app.htm?_flowId=searchFlow       http://localhost/swf-phonebook/app.htm?_conversationId=_c1F0EFA58-F5D0-42EC-47F0-7AFE3CB073D3

  • Request-path based (REST-style):

 

http://localhost/swf-phonebook/app/searchFlow
http://localhost/swf-phonebook/app/_c1F0EFA58-F5D0-42EC-47F0-7AFE3CB073D3

Simplified support for deploying flow definitions for execution.  The FlowRegistry infrastructure makes it possible to deploy a set of flow definitions as a group, where all flows in that group are eligible for execution by a single controller.  Support for wildcard-matching on externalized flow definition resources is also provided:

    <bean name="/app.htm" class="org.springframework.webflow.executor.mvc.FlowController">
        <property name="flowLocator" ref="flowRegistry"/>
    </bean>

    <!-- Creates the registry of flow definitions for this application -->
    <bean id="flowRegistry" class="org.springframework.webflow.registry.XmlFlowRegistryFactoryBean">
        <property name="flowLocations" value="/WEB-INF/flows/**/*-flow.xml"/>
    </bean>

Spring Portlet MVC integration, for executing flows in a JSR 168 Portlet environment.  The Phonebook-portlet demonstrates this integration, configured for use out-of-the-box on Apache Pluto.  Note how the flow definitions between the servlet and portlet version of Phonebook are identical, fully reusable across environments  The Portlet integration requires Spring 2.0 M2 or >.

 

JSF integration, for executing flows in a JSF environment.  The sellitem-jsf sample demonstrates.  The JSF integration requires Spring 1.2.7.  Note how the flow definition between the Spring MVC and JSF versions of sellitem are nearly identical (JSF components handle data binding and validation, so the sellitem-jsf version is slightly more concise).

Improved support for persisting flow executions across requests and tracking ongoing conversations within a repository.  The backing repository strategy is pluggable; use of continuation-based repository allows capturing the state of a conversation at each view state to support restoring from history when using the back button.  Tracking logical conversations allows detection of conversation completion to prevent the possibility of duplicate submit out-of-the-box (with no custom coding required), and allows for conversation scope, a data map shared by all conversation continuations.

Automatic externalized flow definition change detection and “hot reloading”.  Analogous to a JSP resource, a flow definition resource that changes is refreshable on the fly without container restart.

Support for global transitions shared by all states of a flow.  This is particularly useful for view-states that logically share a common-set of navigation actions.  Example:

    <!-- could back a central navigation menu, on header button bar -->
    <global-transitions>
        <transition on=”viewPrice" to="enterPriceAndItemCount"/>
        <transition on="viewCategory" to="enterCategory"/>
        <transition on="viewShipping” to="enterShippingDetails"/>
        <transition on="viewOrderPreview" to="showCostOverview"/>
    </global-transitions>

Support for importing one or more Spring bean definition files into a flow definition, providing a context for configuring custom flow artifacts such as actions, attribute mappers, exception handlers, view selectors, and transition criteria.  Example:

    <view-state id="enterSearchCriteria" view="searchCriteria">
        <transition on="search" to="executeSearch">
            <action bean="formAction" method="bindAndValidate"/>
       </transition>
    </view-state>

    <import resource="search-flow-beans.xml"/>

    - search-flow-beans.xml -
    <beans>
        <!-- Search form action that setups the form and processes form submissions -->
        <bean id="formAction" class="org.springframework.webflow.action.FormAction">
            <property name="formObjectClass" value="phonebook.SearchCriteria"/>
            <property name="formObjectScope" value="FLOW"/>
            <property name="validator">
                <bean class="phonebook.SearchCriteriaValidator"/>
            </property>
       </bean>
    </beans>

Support for “inline-flows”, flow definitions fully local and contained within an outer flow definition:

    <flow start-state="displayItemlist">
        ...
        <inline-flow id="item">
            <flow start-state="displayItem">
                ...
            </flow>
        </inline-flow>
    </flow>

Support for exception handling at both the flow and state level.  A flow can now be configured to take a response action on the occurrence of an exception.  Example:

    <action-state id="executeSearch">
        <action bean="phonebook" method="search(${flowScope.searchCriteria})" resultName="results"/>
        <transition on="success" to="displayResults"/>
        <exception-handler on="phonebook.NoMatchingEntriesException" to="enterSearchCriteria"/>
    </action-state>

Misc improvements in many areas including but not limited to Java-based flow building, flow execution testing, flow execution listening, conversation locking, flow execution serialization, attribute and parameter map access support, flow attribute mapping, and piecemeal page-level form validation.  In general we consider the public SWF API mature and complete; at the same time, an interesting fact about using SWF is you typically rarely depend on that API in application code.

 

ADDITIONAL RESOURCES and WHERE TO START

Spring Web Flow 1.0 EA introduces the first version of the reference manual, providing 50 focused pages on SWF usage.  The manual is available on-line in HTML and PDF forms.

One of the best ways to get started with Spring Web Flow is to review and walkthrough the sample applications.  We recommend reviewing all samples, supplementing with reference manual material as needed from the start.  Nine (9) sample applications ship with the 1.0 EA release, each demonstrating a distinct set of product features.  These samples are:

1. Phonebook - the central sample demonstrating most features (including subflows).
2. Sellitem - demonstrates a wizard with conditional transitions, conversational scope, and continuations.
3. Flowlauncher - demonstrates all the possible ways to launch and resume flows.
4. Itemlist - demonstrates REST-style URLs, conversational redirects to a refreshable conversation URL, and inline flows.
5. (NEW) Shippingrate - demonstrates Spring Web Flow together with Ajax technology (thanks to Steven Devijver)
6. Birthdate - demonstrates Struts integration.
7. Fileupload - demonstrates multipart file upload.
8. (NEW) Phonebook-Portlet - the phonebook sample in a Portlet environment (notice how the flow definitions do not change)
9. (NEW) Sellitem-JSF - the sellitem sample in a JSF environment (notice how the flow definition does not change)

To build the sample applications for deployment in one step simply extract the release archive, access the projects/build-spring-webflow, and execute the ant dist target.  See the release readme.txt and projects/spring-webflow-samples/readme.txt for more information on the release archive contents and samples, respectively.

Thanks to everyone out there who has made Spring Web Flow what it is today—those using it, providing the feedback that makes it stronger.  Special thanks to Ulrik Sandberg for his contribution to our test suite.  1.0 final is just on the horizon—we keenly look forward to your feedback on this release.

Sincerely,

The Spring Web Flow Team

Keith Donald
Erwin Vervaet
Colin Sampaleanu
Juergen Hoeller
Rob Harrop

Comments

Integrating Spring Webflow into a large Struts app

I have a large Struts app with many Action classes. I read the statement:

'Support for binding directly to backing business services from a flow definition. This eliminates the need to code custom Action adapter classes in many cases. What you are left with is what matters: your flow definition and your service-layer. In most cases you don’t depend on SWF APIs at all. '

Does this mean I can use my existing actions somehow? How can I call a regular action with a method signature like

public ActionForward execute(final ActionMapping mapping, final ActionForm form,final HttpServletRequest request, final HttpServletResponse response)

from Spring Webflow? The app is too large to rewrite in order to add Spring Webflow. I'm hoping that I can add it to my existing app. Will this work?

 

 

Upcoming Training

Newsletter Subscription

Our monthly newsletter is packed full of techniques, tutorials, tips and tricks to get you on your way to Spring nirvana. View Archive