【问题标题】:Restarting Spring Web Flow with new model values使用新模型值重新启动 Spring Web Flow
【发布时间】:2014-12-12 22:30:56
【问题描述】:

我正在尝试找到一种方法,如果用户重新启动流程,则值不在其中。如果您查看下面的流程,您可以看到用户输入数据,预览并保存它。保存后,用户可以返回以将新数据输入到输入屏幕,但使用我当前的设置,屏幕显示预-数据。重启时如何清除?

<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>

【问题讨论】:

    标签: spring spring-webflow


    【解决方案1】:

    一种简单的方法是在您的Customer 类上定义一个reset() 方法,然后在&lt;view-state&gt; &lt;on-entry&gt;(如“谢谢”)或&lt;transition&gt;(“重启”)中调用它。

    【讨论】:

    • 我认为这行不通..如果我在预览页面上取消,那么它将没有任何价值
    • 我的第一个建议,没错。不过,你明白了。只需在您想要重新开始的任何转换上调用reset() 方法。 (我会更新我的答案以说明您的取消案例。显然我没有仔细阅读您的整个流程。)
    【解决方案2】:

    你试过了吗:

    <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>
    

    【讨论】:

      【解决方案3】:

      您可以执行外部重定向来执行相同的流程。这是一个例子。

      <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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-23
        • 1970-01-01
        • 2012-03-30
        • 1970-01-01
        • 2012-06-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多