Spring Web Flow: passing values between flows
Let’s imagine the situation that you have main flow and three subflows in that main flow and you want pass values between some of these flows and not to use conversation scope for that.
Scenario is following: I start at main flow and then go to subflow A and get some variable value which I pass back to main flow and then from main flow I go to subflow B and use that variable value (which I setted at subflow A) here.
You may wonder why not to use conversation scope, but due to fact that I don’t need to use that variable at subflow C so there is no need for conversation scope.
In a subflow A I define output parameter isBar and assign a value from flow scope with same name (isBar). Flow scope variable isBar is valid through whole subflow A.
subflow-a-flow.xml
<end-state id="someEndstateName">
<output type="java.lang.Boolean" name="isBar" value="flowScope.isBar" />
</end-state>
And then in main flow I retrieve variable isBar and set it to flow scope variable isFoo which is valid through whole main flow.
main-flow.xml
<subflow-state id="subflowA" subflow="subflow-a-flow">
<transition on="someEndstateName" to="somewhere">
<set type="java.lang.Boolean" name="flowScope.isFoo" value="currentEvent.attributes.isBar" />
</transition>
</subflow-state>
And then again at main flow I set this variable as an input parameter for subflow B.
main-flow.xml
<subflow-state id="subflowB" subflow="subflow-b-flow">
<input type="java.lang.Boolean" name="isQux" value="flowScope.isFoo" required="false" />
</subflow-state>
And finally retrive this parameter at subflow B.
subflow-b-flow.xml
<input name="isQux" type="java.lang.Boolean" required="false" />
One last note, in examples above I was using Spring Web Flow version 2.3.3.RELEASE.