Results 1 to 4 of 4

Thread: ending subflow and flow together

  1. #1
    Join Date
    Jun 2008
    Posts
    5

    Default ending subflow and flow together

    Hi,

    I am facing some problems when ending a subflow together with the parent flow.

    My scenario is :
    - from a view in flow A, I enter in a subflow B
    - in that subflow B, I navigate between state until I reach the end-state
    of flow B which also has a view state defined (this is the view state i would actually like to go to)
    - Since my subflow B ends, I return to flow A, which also ends
    - Since flow A is ended, the first screen of flow A is rendered again.

    What I would like (and expected) to happen is that my browser would show the view of the endstate defined in subflow B (since there is no view defined for the endstate in flow A)

    Is there any way to achieve this? I cannot use this same view in the endstate of flow A since it uses flowscoped variables from subflow B.

    Thanks,
    Kristof

  2. #2
    Join Date
    Feb 2009
    Location
    Denmark
    Posts
    21

    Default

    Quote Originally Posted by Kristof View Post
    Hi,

    I am facing some problems when ending a subflow together with the parent flow.

    My scenario is :
    - from a view in flow A, I enter in a subflow B
    - in that subflow B, I navigate between state until I reach the end-state
    of flow B which also has a view state defined (this is the view state i would actually like to go to)
    - Since my subflow B ends, I return to flow A, which also ends
    - Since flow A is ended, the first screen of flow A is rendered again.

    What I would like (and expected) to happen is that my browser would show the view of the endstate defined in subflow B (since there is no view defined for the endstate in flow A)

    Is there any way to achieve this? I cannot use this same view in the endstate of flow A since it uses flowscoped variables from subflow B.

    Thanks,
    Kristof
    The view-attribute on end-state is ignored when the flow is running as a subflow.

    Perhaps you could return the variables from subflow B to A, so that flow A can use the view you have currently defined in flow B... or you could put the variables in conversation-scope.

    However, If you always end flow A when flow B ends, then is there any reason for flow B to be a subflow of A? - other than you would like to go back to the page (A) you came from when B ends?
    Flow A could do a flowredirect to B instead, then the end-state in B would actually use the view-attribute since B is now a master flow.
    To be able to navigate back to A, you could then insert a regular html href link which links back to the page of flow A.

  3. #3
    Join Date
    Jun 2008
    Posts
    5

    Default

    Quote Originally Posted by joensson View Post
    The view-attribute on end-state is ignored when the flow is running as a subflow.

    Perhaps you could return the variables from subflow B to A, so that flow A can use the view you have currently defined in flow B... or you could put the variables in conversation-scope.

    However, If you always end flow A when flow B ends, then is there any reason for flow B to be a subflow of A? - other than you would like to go back to the page (A) you came from when B ends?
    Flow A could do a flowredirect to B instead, then the end-state in B would actually use the view-attribute since B is now a master flow.
    To be able to navigate back to A, you could then insert a regular html href link which links back to the page of flow A.
    Thanks for the quick reply!

    Putting the variables in conversation-scope is idd an option.
    The reason why flow B is a subflow of A is that B can be called from yet another flow C or B can even be a flow on its own too.

    What exactly did you mean by a flowredirect? Does this mean that flow A has ended and flow B is started with some input parameters? That would be exactly what we need here. How can we achieve this?

  4. #4
    Join Date
    Feb 2009
    Location
    Denmark
    Posts
    21

    Default

    Quote Originally Posted by Kristof View Post
    Thanks for the quick reply!

    Putting the variables in conversation-scope is idd an option.
    The reason why flow B is a subflow of A is that B can be called from yet another flow C or B can even be a flow on its own too.
    You're welcome and ok I see now why it is that way.

    Quote Originally Posted by Kristof View Post
    What exactly did you mean by a flowredirect? Does this mean that flow A has ended and flow B is started with some input parameters? That would be exactly what we need here. How can we achieve this?
    You can make redirects in both view-states and in end-states. If you need flow A to end before going to flow B, you should make the redirect in an end-state.
    See http://static.springframework.org/sp...dler-redirects

    I know that the doc does not mention flowRedirect: but it is supported in Web Flow 2 in FlowModelFlowBuilder.java:
    Code:
    private ViewFactory parseViewFactory(String view, String stateId, boolean endState, BinderModel binderModel) {
    		if (!StringUtils.hasText(view)) {
    			if (endState) {
    				return null;
    			} else {
    				view = getLocalContext().getViewFactoryCreator().getViewIdByConvention(stateId);
    				Expression viewId = getLocalContext().getExpressionParser().parseExpression(view,
    						new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class));
    				return createViewFactory(viewId, binderModel);
    			}
    		} else if (view.startsWith("externalRedirect:")) {
    			String encodedUrl = view.substring("externalRedirect:".length());
    			Expression externalUrl = getLocalContext().getExpressionParser().parseExpression(encodedUrl,
    					new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class));
    			return new ActionExecutingViewFactory(new ExternalRedirectAction(externalUrl));
    		} else if (view.startsWith("flowRedirect:")) {
    			String flowRedirect = view.substring("flowRedirect:".length());
    			Expression expression = getLocalContext().getExpressionParser().parseExpression(flowRedirect,
    					new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class));
    			return new ActionExecutingViewFactory(new FlowDefinitionRedirectAction(expression));
    		} else {
    			Expression viewId = getLocalContext().getExpressionParser().parseExpression(view,
    					new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class));
    			return createViewFactory(viewId, binderModel);
    		}
    Last edited by joensson; Feb 12th, 2009 at 05:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •