【问题标题】:open new flow from another flow从另一个流打开新流
【发布时间】:2015-02-11 21:24:21
【问题描述】:

我们有一个具有多种功能的“主页”,其中之一是帐户命令链接。主页在 main-flow.xml 中定义(见下文),当我们单击此链接时,应该会打开新流程。

ma​​in_page.xhtml 文件:

<h:commandLink value="Account" target="_blank" action="account"/>

ma​​in-flow.xml 文件:

<view-state id="main_page">

<transition-state on="account" to="newFlowOpen"/>

</view-state>

<view-state id="newFlowOpen" view="/Report/account.xhtml"/>

但是当我们点击这个链接时,不是像 e2s1 那样打开新的流,而是像 e1s2 那样简单地打开新的执行键和相同的流执行,这是错误的。 请告诉我这个:(

【问题讨论】:

    标签: jsf-2 spring-webflow-2


    【解决方案1】:

    因为您在 main-flow.xml 中添加了“newFlowOpen”作为视图状态,因此它是 main-flow.xml 的一部分,而不是独立的独立流程。

    如果您想创建一个独立的独立流程,您需要在它自己的路径中创建一个新的“account-flow.xml”。完成此操作后,单击“主页”上的帐户链接将离开现有流程并创建一个新的帐户流程。

    如果保持/记住主流状态很重要... 可选(在完成上述操作之后),您可以将新创建​​的独立帐户流嵌入到主流中一个子流。

    在父->子流之间创建子流关系的原因:

    • 当您想在 2 个流之间传递参数或 POJO 时(不将参数嵌入 url 内)

    • 当您想要保留父流的当前状态并在子流完成后返回父流时。

    以下是如何创建子流的一个很好的示例:

    http://www.springbyexample.org/examples/spring-web-flow-subflow-webapp.html

    <!-- You would place the subflow-state below inside main-flow.xml -->
    
        <subflow-state id="accountSubflow" subflow="account"> 
            <input name="id" value="accountId"/> <!-- input to send to subflow-->
            <input name="person" value="person" type="foo.bar.entities.Person"/> <!-- input to send to subflow for pojos you have explicitly declare the type-->
    
            <output name="boolSuccess" /> <!-- output returned by the subflow -->
    
            <transition on="save" to="saveForm"/>  <!-- "save" = id of the <end-state id="save"> inside the subflow -->
            <transition on="cancel" to="cancelForm" /> <!-- "cancel" = id of the <end-state id="cancel"> inside the subflow -->
        </subflow-state>
    

    【讨论】:

      猜你喜欢
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      • 2012-05-26
      • 2012-02-12
      • 1970-01-01
      • 2012-11-16
      相关资源
      最近更新 更多