Lukas Grygar's

Personal enterprise Java web development blog.

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.


<end-state id="someEndstateName">
	<output type="java.lang.Boolean" name="isBar" value="flowScope.isBar" /> 

And then in main flow I retrieve variable isBar and set it to flow scope variable isFoo which is valid through whole main flow.


<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" />

And then again at main flow I set this variable as an input parameter for subflow B.


<subflow-state id="subflowB" subflow="subflow-b-flow">
	<input type="java.lang.Boolean" name="isQux" value="flowScope.isFoo" required="false" />

And finally retrive this parameter at subflow B.


<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.

Tags: java  spring  spring-web-flow  spring-webflow 

Share on: Twitter  Facebook  Google+ 

Previous post: How to uninstall (remove) Oracle Database 11g on Microsoft Windows 7

Related posts: