View Full Version : how to return from subflow to the state from it was executed
kajism
Jul 27th, 2005, 04:42 AM
Hi,
Let's say, In my flow I have two view-states displaying employee form: create and edit. There is a drop-down for selecting companies on the form - here I want to give the user a possibility to add new company by running a subflow and when it finishes it should return back. But I have to hardcode the transition from subflow end state which could be called from create or edit...
Is there a solution for this? Must the transition after subflow be mandatory?
Thanks,
Karel
klr8
Jul 27th, 2005, 10:40 AM
There are several ways to do it. You could have a seperate subflow-state for each of the view-states, hard-coding to which view it should return. Alternatively, you could 'remember' (in flow scope) in the parent flow whether you're viewing or editing, and use that information in a decision-state after returning from the subflow. Another option is conditional transitions in the subflow state, basically merging the decision state and the subflow state, e.g.
<subflow-state ...>
...
<transition on="${result.success and flowScope.mode=='EDIT'}" to="..."/>
<transition on="${result.success and flowScope.mode=='VIEW'}" to="..."/>
</subflow-state>
There are more alternatives ofcourse...
Erwin
DarthWeasel
Jun 11th, 2009, 09:37 AM
I have to do the same type of thing
Is there a way that the to="..." can be dynamic?
for instance instead of
<transition on="saved" to="availability">
something like
<transition on="saved" to="${some expression to get a state by name}">
?
InverseFalcon
Jun 11th, 2009, 11:54 AM
I'm pretty sure dynamic values for the "to" attribute are allowed too.
DarthWeasel
Jun 11th, 2009, 12:13 PM
After playing with it for a bit it seems that passing in a string of the state id works which is pretty cool.
so for example
you can do stuff like
<set name="flowScope.saveOrderReturnState" value="'stateToReturnTo'"/>
...
<transition on="saved" to="${flowScope.saveOrderReturnState}">
where stateToReturnTo is a stateId
<view-state id="stateToReturnTo">
...
This solves my issue.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.