2012-07-26 71 views
0

我想找到一種方法,如果用戶重新啓動流程,則不在其中。如果你看看下面的流程,你可以看到用戶輸入數據,預覽並保存。保存後,用戶可以返回輸入新數據到輸入屏幕,但使用我當前的設置,屏幕顯示pre -數據。我如何在重新啓動時清除它?使用新的模型值重新啓動Spring Web Flow

<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-2.0.xsd"> 

    <var name="customer" class="org.uftwf.domain.Customer"/> 

    <view-state id="helloworld" view="input.jsp" model="customer" popup="true"> 
    <transition on="submit" to="preview" /> 
    <transition on="cancel" to="thanks" validate="false"/> 
    </view-state> 

    <view-state id="preview" model="customer"> 
    <transition on="cancel" to="helloworld"/> 
    <transition on="accept" to="save"> 
     <evaluate expression="hellowWorldFlowActions.addCustomer(customer)"/> 
    </transition> 
    </view-state> 

    <view-state id="save" model="customer"> 
    <transition on="accept" to="thanks"/> 
    </view-state> 

    <view-state id="thanks"> 
    <transition on="restart" to="helloworld"/> 
    </view-state> 
</flow> 

回答

0

一個簡單的方法是定義你的Customerreset()方法,並呼籲在哪個<view-state><on-entry>(如「謝謝」)或<transition>(「重啓」)是有道理的。

+0

我不認爲這會工作..如果我在預覽頁面上取消它不會有任何價值,然後 – 2012-07-26 17:15:25

+0

我的第一個建議,這是真的。不過,你明白了。只要調用你想從新開始的任何轉換的'reset()'方法。 (我會更新我的回答,以解釋你的取消情況。顯然,我沒有仔細閱讀你的整個流程。) – dbreaux 2012-07-26 17:35:07

0

你試過:

<view-state id="helloworld" view="input.jsp" model="customer" popup="true"> 
     <on-entry> 
       <set name="flowScope.costumer" value="new org.uftwf.domain.Customer()" /> 
     </on-entry> 
     <transition on="submit" to="preview" /> 
     <transition on="cancel" to="thanks" validate="false"/> 
</view-state> 
0

你可以做一個外部重定向做同樣的流程。這是一個例子。

<var name="customer" class="org.uftwf.domain.Customer"/> 

<view-state id="thanks"> 
    <transition on="restart" to="doRestart"/> 
</view-state> 

<end-state id="doRestart" view="externalRedirect:nameOfThisFlow"></end-state>