如何退出流程? [英] How to exit a flow?

查看:164
本文介绍了如何退出流程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我输入了Faces Flow,我想通过转到不属于该流程的任何页面来退出它.

Once I've entered a Faces Flow, I want to exit it by going to any page that is not part of the flow.

问题在于,如果我出门(例如通过h:link),流不会被破坏. 确实,如果再次单击作用为flowId的h:commandButton,我将返回上一个流程,而不是创建新的流程.

The problem is that the flow is not destroyed if I go outside, for example via an h:link. Indeed, if I click again on a h:commandButton whose action is the flowId, I go back to the previous flow instead of creating a new flow.

如何在不让用户明确单击其动作对应于流的返回节点的h:commandButton的情况下退出流? 甚至有可能吗?

How to exit a flow without having the user to click explicitly on a h:commandButton whose action corresponds to the return node of the flow ? Is it even possible ?

让我们以这个流程为例(来自

Let's take this flow for example (from the JEE 7 samples)

@Produces @FlowDefinition
public Flow defineFlow(@FlowBuilderParameter FlowBuilder flowBuilder) {
    String flowId = "flow1";
    flowBuilder.id("", flowId);
    flowBuilder.viewNode(flowId, "/" + flowId + "/" + flowId + ".xhtml").markAsStartNode();

    flowBuilder.returnNode("taskFlowReturn1").
            fromOutcome("#{flow1Bean.returnValue}");
    flowBuilder.returnNode("goHome").
            fromOutcome("#{flow1Bean.homeValue}");

    flowBuilder.inboundParameter("param1FromFlow2", "#{flowScope.param1Value}");
    flowBuilder.inboundParameter("param2FromFlow2", "#{flowScope.param2Value}");

    flowBuilder.flowCallNode("call2").flowReference("", "flow2").
            outboundParameter("param1FromFlow1", "param1 flow1 value").
            outboundParameter("param2FromFlow1", "param2 flow1 value");

    return flowBuilder.getFlow();
}

如果用户单击,流程将终止

The flow will be terminated if the user clicks on

<h:commandButton id="index" value="home" action="goHome" />

<h:commandButton id="return" value="return" action="taskFlowReturn1" />

但是,如果用户点击

<h:link outcome="someOutcomeUnrelatedToTheFlow"/>

还是用户在不删除jfwid的情况下更改了浏览器中的url?似乎流没有终止,但是用户实际上是在流之外浏览.

Or if the user changes the url in the browser, without removing the jfwid? It seems the flow isn't terminated but the user is actually browsing outside of the flow.

这对我来说有点奇怪:如果没有用户对commandButton/commandLink的特定操作,我找不到退出流程(释放后备bean)的任何方法.

That seems a bit odd to me: I can't find any way to exit the flow (and release the backing beans) without a specific action from the user on a commandButton/commandLink.

顺便说一句:我正在WildFly 8 CR1上对此进行测试.

Btw: I'm testing this on WildFly 8 CR1.

推荐答案

您是对的.在当前版本中,该规范要求使用UICommand组件进行导航,以确定流是否已退出.但是,这对于使用GET进行导航的任何体面的使用场景是不够的.

You are right. In the current version, the spec requires to navigate using UICommand components to determine if the flow is exited or not. However, this is not sufficient for any decent usage scenario where navigation happens using GET.

尽管规范在概念上存在差距,但仍可以实施一种解决方案,并且我希望在即将发布的JSF库版本中看到一个解决方案(实际上, OmniFaces 是一个很好的选择,例如 BalusC

Notwithstanding the specs conceptual gap, a solution may be implemented and I expect to see one in upcoming versions of JSF libraries (actually, OmniFaces is a good bet, as BalusC and Arjan focus on fixing stuff that was left out in the spec ;-) ).

从技术上讲,一种解决方案可能看起来像这样:使用h:linkh:button时,已经添加了jfwid参数.因此,如果请求了流定义之外的视图,则可以使用PhaseListener结束当前流.但是,这只是一个基本概念,可能存在我尚未考虑的绊脚石.

Technically speaking, a solution may look like this: The jfwid param is already added when h:linkor h:button is used. So a PhaseListener could be used to end the current flow if a view outside of the flows definition is requested. However, this is just a basic idea and there may be stumbling blocks which I did not consider yet.

因此,要回答您的问题:当前,退出流的唯一正确方法是导航到退出节点或使用h:commandLinkh:commandButton进行页面导航,因为这也将结束流当请求在流定义之外的视图时.

So, to provide an answer to your question: Currently the only correct way to exit a flow is to either navigate to an exit node or to use h:commandLinkor h:commandButton for page navigation as this will also end a flow when a view outside of the flows definition is requested.

这篇关于如何退出流程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆