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 社群所有即將舉行的活動。

檢視所有