Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Webflow, return to main flow from any sub-flow

I'm trying to return to my main flow in spring, from any of my subflows just by clicking a button.

when I use <end-state> it just goes to the previous flow, which is also a sub-flow in the application.

Any ideas?

like image 708
fsonmezay Avatar asked Apr 27 '11 14:04

fsonmezay


1 Answers

You just need the appropriate transitions in each subflow-state in the calling flow to do what you want. The end-state id in your subflow is what will be used as the event id you can transition on in your calling flow.

A subflow can be thought of as a branch of execution. So when your subflow is finished, control is returned back to the calling flow. Think of your end-state as a return statement (and the id attribute as the value returned -- you can also set output attributes but that is not important here).

When your subflow terminates, control is returned backed to the calling flow. The calling flow should define a transition that determines how to handle this event. The event id you will see is the id of the end-state in your subflow.

So in your subflow if you have the following end-state:

<end-state id="back"/>

You can then handle this transition in the flow that called the subflow:

<subflow-state id="do-some-sub" flow="some-sub">
    < ... input variables, expressions, etc ... />
    <transition on="back" to="some-state"/>
</subflow-state>

Note that some-state here can also be an end-state. Your situation sounds like you have a main flow that calls a subflow which in turn calls another subflow. So you would want some-state to be an end-state, which would then be handled by its calling flow (in your case the "main" flow).

like image 70
David Avatar answered Sep 23 '22 01:09

David