spring-webflow
spring-webflow copied to clipboard
Unable to fork off flow independent flow executions from inside a flow using externalRedirect [SWF-322]
nebhale opened SWF-322 and commented
Currently using an externalRedirect from a view-state, you can redirect to a flow definition URL, but the FlowExecutorArgumentHandler will append the flow execution key of the paused flow to the URL with the expectation it will be passed forked off flow. Unfortunately, the FlowExecutionArgumentHandler is picking up the _flowExecutionKey and is treating it as a refresh against FlowExecution causing an infinite loop. Had the flowExecutionKey been named another parameter, this conflict would not have happened as the key would not have been captured and interpreted as a refresh.
This feature is useful in spawning a nested conversation and allowing the child flow to return data back to the outer flow and end with no possibility of resuming.
The flowRedirect does not exhibit this behavior because it does not append the _flowExecutionKey to the redirect URL. If the name of the key variable is changed, the flowRedirect should pass this argument as well.
In general we should examine whether this feature should be supported. As it stands now it is not completely functional, but seems to be available. We should examine creating a forked subflow as a first class concept.
To spawn the subflow, you'd have a view-state with an externalRedirect: <view-state id="startRemoveFlow" view="externalRedirect:/accounts/flows.htm?_flowId=removeBeneficiary-flow&accountId=${flowScope.accountId}&beneficiaryName=${requestParameters.beneficiaryName}"> <transition on="removeFinished" to="editBeneficiaries"/> </view-state>
which currently creates a redirect URL of: http://localhost:8080/webflow-1-solution/accounts/flows.htm?_flowId=removeBeneficiary-flow&accountId=0&beneficiaryName=Corgan&_flowExecutionKey=_c6A6C37EF-D74D-DC14-0103-2E898D44C0FB_k0AD1E680-82F4-2302-53F1-D556EAC59DDC
To return from the subflow you'd have an end-state with externalRedirect with the original flowExecutionKey: <end-state id="returnToEdit" view="externalRedirect:/accounts/flows.htm?_flowExecutionKey=${flowScope.oldFlowExecutionKey}&_eventId=removeFinished"/>
Affects: 1.0.3
Issue Links:
- #124 Add support for Flow Composition ("depends on")
1 votes, 1 watchers
nebhale commented
The ideal situation would be to add native support for the concept of a forked sub-flow so that you would not need to pass around keys like the example. You'd want to see something like:
<subflow-state id="removeBeneficiary" flow="removeBeneficiary-flow" fork="true"> <attribute-mapper> <input-mapper> <input-attribute name="accountId"/> <mapping source="requestParameters.beneficiaryName" target="beneficiaryName" /> </input-mapper> </attribute-mapper> <transition on="finish" to="editBeneficiaries"/> </subflow-state>
Erwin Vervaet commented
A few comments:
- We need to investigate how this relates to the 'parrallel subflows' feature request
- How common is this requirement? You could just do it with a custom ViewSelector (bean:...)
- Not sure wheter we should do this via a ViewSelector or using customizations in the subflow-state. A ViewSelector seems to be more appropriate. If we do it in a subflow state, we get an extra state that can 'pause' the flow execution...