如何使用FlowScoped设置除默认节点之外的另一个起始节点?

时间:2016-05-02 13:20:01

标签: jsf cdi jboss-weld weld flow-scope

Anghel Leonard的书摘录

  

<view tag>:它嵌套在<flow-definition>标记中并表示   表示流节点的JSF页面;它关联一个显式ID   到每个页面(Facelet)路径(此外,您可以参考每个页面   它的ID)。页面路径映射在嵌套的<vdl-document>标记中   <view>标记。此标记的存在是可选的,但作为一个   约定,至少指示起始节点的<view>标记(开始   页面)存在,特别是如果你想设置另一个起始节点   除了默认值之外,它由流程中的页面表示   与流程具有相同的名称(ID)。此外,您可以使用可选项   <start-node>ID</start-node>标记并指明<view>标记的ID   映射自定义起始页面。作为替代,开始节点   可以通过设置id属性的值来指示流的流量   标签作为流ID,以及封装的内容    tag作为自定义起始页面的路径。当你   参考流ID,JSF将转到该页面并自动放入   你在流动中。

假设我有4个相对于webapp目录的页面,如下所示:

index.xhtml
registration/registration.xhtml
registration/confirm.xhtml
done.xhtml

作者在faces-config.xml

中建议此设置
<flow-definition id="registration">
        <view id="registration">
            <vdl-document>/registration/registration.xhtml</vdl-document>
        </view>
        <flow-return id="taskFlowReturnIndex">
            <from-outcome>/index</from-outcome>
        </flow-return>
        <flow-return id="taskFlowReturnDone">
            <from-outcome>/done</from-outcome>
        </flow-return>
</flow-definition>

我已经进行了实验,并且确实知道了,

<view id="registration">
    <vdl-document>/registration/registration.xhtml</vdl-document>
</view>

是可选的,同一作者也提出。

这就足够了(id属性与JSF视图的名称相同,需要创建流。) -

<flow-definition id="registration">
...
 </flow-definition

此外,仅当id的{​​{1}}属性与JSF视图的名称完全匹配时才会创建流程,即:

<flow-definition id="registration">。XHTML

重复相同提取物的一部分:

  

...至少表示起始节点(起始页)的registration标签是   现在,特别是如果你想<view>除了。{   set another start node,由流中的页面表示   default one作为流程。此外,您可以使用可选项   same name (ID)标记并指明<start-node>ID</start-node>标记的ID   映射自定义起始页面。

用更简单的话来说,他建议这样做要嵌套在同一个<view>中,

<flow-definition>

但是我发现从<view id="confirm"> <vdl-document>/registration/confirm.xhtml</vdl-document> </view> <start-node>confirm</start-node> index.xhml不会返回confirm.xhtml

true

当一个人从In flow ? #{null != facesContext.application.flowHandler.currentFlow} 导航到index.xhtml时。

有什么建议吗?

0 个答案:

没有答案