2012-07-26 69 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>