Reuse states from Spring Web flow definitions?

145 Views Asked by At

I have, for example, 2 flows that should end in the same transitions to the same states, e.g.,

Flow 1 ends in either go to state A or B. Flow 2 ends in either go to state A or B.

Right now, I seem to need to define the same end-state for A and B in flow1.xml and flow2.xml.

Is there any way they can all share the same states, A and B?

I've tried creating something like flowState and defining two end states in it, and trying to refer to them in flows 1 and 2 like

flowState#stateA and flowstate#stateB

but no luck. Any help??

1

There are 1 best solutions below

0
On

Refactor the common state in a subflow, and call the subflow from the different main flows where you want to reuse the state.

You can even pass parameters to the subflow to configure it using the spring expression language if needed.