Spring Web Flow 1.0 RC4 发布

发布 | Keith Donald | 2006 年 10 月 5 日 | ...
亲爱的 Spring 社区成员:
 
我们很高兴宣布 Spring Web Flow 1.0 RC4 已发布。
 

 

Spring Web Flow 是 Spring 社区的一个产品,专注于协调 Web 应用程序中的用户界面流程。

此版本包含许多改进和几个令人兴奋的新功能。  我们认为它是迄今为止最稳定的版本,并且最终,此版本使 Spring Web Flow 1.0 最终路线图的功能已完成。  Spring Web Flow 1.0 最终版将在下周发布,改动最小。  从现在到那时,我们鼓励您测试 1.0 RC4,以便在 1.0 正式发布之前帮助发现任何剩余问题。

请注意,此版本中存在影响用户的更改。  1.0 RC3 或更早版本的用户应查阅 升级指南,其中详细概述了这些更改。

1.0 RC4 中的新增和重要特性列表令人兴奋,包括: 

新增和重要特性

作为 Spring Web Flow 1.0 最终版之前的最后一个发布候选版本,Spring Web Flow 1.0 RC4 引入了强大的新功能,例如渲染操作 (1)、评估操作 (2)、设置操作 (3)、闪存范围 (4)、流程执行属性 (5) 和暂停时始终重定向 (6)。它提供了增强的文档、更好的流程定义验证、智能默认值以及用于配置流程执行引擎的完整自定义 Spring 2.0 配置模式 (7)。

  • (1) 渲染操作在响应被渲染之前执行应用程序行为。  当请求视图状态进行可渲染视图选择时,或者在重定向或浏览器刷新按钮触发的刷新时,会调用渲染操作。  以下示例展示了一个在渲染结果视图之前执行电话簿搜索的渲染操作。

    <view-state id="displayResults" view="searchResults">
        <render-actions>
            <bean-action bean="phonebook" method="search">
                <method-arguments>
                    <argument expression="flowScope.searchCriteria"/>          
                </method-arguments>
                    <method-result name="results"/>
            </bean-action>
        </render-actions>
        <transition on="newSearch" to="enterCriteria"/>
        <transition on="select" to="browseDetails"/>
    </view-state>

  • (2) 评估操作根据流程执行状态评估表达式。  表达式(默认为基于 OGNL)可以针对流程执行的根 RequestContext 可访问的任何对象,包括任何范围(例如流程范围)中的对象。  以下示例展示了一个评估操作,它在“game”流程范围 bean 上调用“makeGuess”方法
    <action-state id="makeGuess">
        <evaluate-action expression="flowScope.game.makeGuess(requestParameters.guess)">
            <evaluation-result name="guessResult"/>
        </evaluate-action>
        <transition on="CORRECT" to="showAnswer"/>
        <transition on="*" to="enterGuess"/>
        <transition on-exception="java.lang.NumberFormatException" to="enterGuess"/>
    </action-state>
  • (3) 设置操作设置范围类型(例如流程范围)中的属性值。  属性可以是顶级属性,也可以是嵌套属性路径上的属性。  以下示例展示了一个设置操作,它将“fileUploaded”属性在闪存范围中设置为“true”。
    <action-state id="uploadFile">
        <action bean="uploadAction" method="uploadFile"/>
        <transition on="success" to="selectFile">
            <set attribute="fileUploaded" scope="flash" value="true"/>
        </transition>
    </action-state>
  • (4) 闪存范围是一种新的范围类型,用于在重定向和视图的任何刷新之间持久化属性。  当发出事件信号以退出视图时,闪存范围将被清除。  以下完整的流程定义示例展示了如何使用闪存范围将“fileUploaded”属性暴露给 selectFile 视图状态,以便在成功上传后显示成功消息。
    <flow xmlns="http://www.springframework.org/schema/webflow"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.springframework.org/schema/webflow
                                           http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
   
        <start-state idref="selectFile"/>
       
        <view-state id="selectFile" view="fileForm">
            <transition on="submit" to="uploadFile"/>
        </view-state>
   
        <action-state id="uploadFile">
            <action bean="uploadAction" method="uploadFile"/>
            <transition on="success" to="selectFile">
                <set attribute="fileUploaded" scope="flash" value="true"/>
            </transition>
        </action-state>
       
    </flow>
  • (5) 流程执行属性允许您设置自定义属性,这些属性可以影响流程执行行为。  以下示例显示了在 Portlet 环境中(重定向通常不适用)将“alwaysRedirectOnPause”属性设置为 false 的指令。
    <flow:executor id="flowExecutor" registry-ref="flowRegistry">
        <flow:execution-attributes>
            <flow:alwaysRedirectOnPause value="false"/>
        </flow:execution-attributes>
    </flow:executor>
  • (6) “暂停时始终重定向”为您提供默认的 POST+REDIRECT+GET 行为,无需特殊编码。 现在默认情况下,当进入视图状态时,会自动发出重定向。  这会触发对流程执行 URL 的刷新,该 URL 在会话处于活动状态时保持稳定。
  • (7) 新的 Spring 2.0 配置方言极大地简化了系统配置,并提供了强大的验证和工具支持。  现在配置 webflow 的基础设施就像定义两个元素一样简单,如下面的完整示例所示
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:flow="http://www.springframework.org/schema/webflow-config"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
               http://www.springframework.org/schema/webflow-config
               http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd">
   
        <!-- Launches new flow executions and resumes existing executions. -->   
        <flow:executor id="flowExecutor" registry-ref="flowRegistry"/>
       
        <!-- Creates the registry of flow definitions for this application -->
        <flow:registry id="flowRegistry">
            <flow:location path="/WEB-INF/flows/**-flow.xml"/>
        </flow:registry>
       
    </beans>

有关这些功能的更多信息,请参阅参考手册。  Spring Web Flow 1.0 RC4 进一步完善了参考文档,提供了 70 页关于 SWF 使用的说明。  该手册可在线获取,格式为 HTMLPDF

入门指南

学习 Spring Web Flow 的最佳方法之一是查看和演练示例应用程序。  我们建议从一开始就查看所有示例,并根据需要补充参考手册材料。该版本附带了十个示例应用程序,每个应用程序都演示了一组独特的产品功能。  这些示例是

  1. Phonebook - 演示了大多数功能(包括子流程)的原始示例
  2. Sellitem - 演示了一个带有条件转换、流程执行重定向、自定义文本字段格式和续流的向导
  3. Flowlauncher - 演示了启动和恢复流程的所有可能方式
  4. Itemlist - 演示了 REST 风格的 URL 和内联流程
  5. Shippingrate - 演示了 Spring Web Flow 与 Ajax 技术的结合
  6. NumberGuess - 演示了有状态 Bean、评估操作和“单键”流程执行重定向。
  7. Birthdate - 演示了 Struts 集成
  8. Fileupload - 演示了多分部文件上传、设置操作和闪存范围
  9. Phonebook-Portlet - Portlet 环境中的电话簿示例(请注意流程定义如何没有改变)
  10. Sellitem-JSF - JSF 环境中的 sellitem 示例

要快速评估并构建示例应用程序,只需

  1. 解压 spring-webflow-1.0-rc4.zip 发布存档
  2. 进入 projects/spring-webflow/build-spring-webflow 目录
  3. 执行 "ant dist" 目标。
  4. 请参阅“target/artifacts”目录,其中包含每个示例的可部署 .war 文件以及已解压的 war 目录。
请参阅 release readme.txt 和 projects/spring-webflow/spring-webflow-samples/readme.txt,分别获取有关发布存档内容和示例的更多信息。

所有示例项目都是 Spring IDE 项目,可以直接导入 Eclipse。

感谢所有支持此版本的朋友们。  Spring Web Flow 1.0 终于... 就在眼前了。

祝您使用愉快!

Spring Web Flow 团队

订阅 Spring 新闻通讯

通过 Spring 新闻通讯保持联系

订阅

领先一步

VMware 提供培训和认证,助您快速进步。

了解更多

获取支持

Tanzu Spring 在一个简单的订阅中提供对 OpenJDK™、Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将举行的活动

查看 Spring 社区所有即将举行的活动。

查看全部