Spring Web Flow 1.0 RC4 发布

发布 | Keith Donald | 2006 年 10 月 05 日 | ...
亲爱的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. 电话簿 - 演示大多数功能(包括子流程)的原始示例
  2. 售卖商品 - 演示带有条件转换、流程执行重定向、自定义文本字段格式和续期的向导
  3. 流程启动器 - 演示启动和恢复流程的所有可能方式
  4. 项目列表 - 演示 REST 风格的 URL 和内联流程
  5. 运费 - 演示 Spring Web Flow 与 Ajax 技术结合使用
  6. 猜数字 - 演示有状态 bean、评估动作和“单一键”流程执行重定向。
  7. 生日 - 演示 Struts 集成
  8. 文件上传 - 演示多部分文件上传、设置动作和闪存范围
  9. 电话簿-Portlet - Portlet 环境中的电话簿示例(请注意流程定义没有改变)
  10. 售卖商品-JSF - JSF 环境中的售卖商品示例

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

  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 社区所有即将举行的活动。

查看所有