Once I've entered a Faces Flow, I want to exit it by going to any page that is not part of the flow.
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.
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 ?
Edit:
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" />
or
<h:commandButton id="return" value="return" action="taskFlowReturn1" />
But what if the user clicks on
<h:link outcome="someOutcomeUnrelatedToTheFlow"/>
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.
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.
Btw: I'm testing this on WildFly 8 CR1.