If I understood your problem correctly - you wanted to terminate the current flow but still have the menu click work - is that right?
If it is, have a global common flow that is inherited by all your subflows. Then, add this in the flow
tag of each of your flows, where commonFlow
is the name or ID of your global flow definition file.
parent="commonFlow"
In this global flow definition, define the transition for the menu option:
<global-transitions>
<!-- If Menus are triggered on flows, we end them first. -->
<transition on="menuClick" to="endCurrentFlowThenMenu"/>
</global-transitions>
And then define a redirect for the menu:
<end-state id="endCurrentFlowThenMenu" view="flowRedirect:menuView"></end-state>
However, this only works when current flow is a parent/top-level flow. If it is a subflow, it gets a little bit dirty - you need a work-around so that all subflows are ended first:
<global-transitions>
<!-- If Menus are triggered on flows and subflows, we end them first. -->
<transition on="menuClick" to="endCurrentFlowThenMenuLevel1"/>
<transition on="endCurrentFlowThenMenuLevel1" to="endCurrentFlowThenMenuLevel2"/>
</global-transitions>
In which case you define the matching end states:
<end-state id="endCurrentFlowThenMenuLevel1" view="flowRedirect:newFlow">
</end-state>
<end-state id="endCurrentFlowThenMenuLevel2" view="flowRedirect:newFlow">
</end-state>
The reason why I repeat the view
attribute on each end state is so that it could still work even if the current flow is a top-level flow. Depending on the maximum deepest subflow, you need have multiple transitions and end states to match them (i.e. if you max deepest functionality can have 2 subflows, repeat the above 3 times).
The trick here is, if the current flow is already a top level flow, SWF would not bubble up the parent and will just execute the flowRedirect
.
If, however, the current flow is a subflow, SWF will not execute the redirect on the subflow, but instead will bubble up to the parent first, looking for a matching transition for the current subflow that just ended. It would continue doing this until it finds the top-level flow in which case it would execute the redirect, effectively ending all subflows in the process as well.