Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: How to configure a global transition for a back button?

  1. #21
    Join Date
    Jul 2009
    Posts
    7

    Default

    Hi Oliver,

    just successfully used your BackToLastViewStateFlowExecutionListener for global back transition inside my flow. Do you have also a solution for using this listender over subflows too. In my example I have one main flow (view1, view2, subflow1, view3) calling one subflow (subview1 and subview2). In this example your listender-implementation does not work because the previousViewStateId hold a view-state of the main flow which is not known inside the subflow.

    Do you have any suggestions how to extend this listener?

    Thanks, Harald

  2. #22
    Join Date
    May 2011
    Posts
    2

    Default

    Quote Originally Posted by Rajendra View Post
    Not able to find the method context.getLastEvent().It gives me compile error saying not able to find method getLastEvent()

    I am using SWF 2.0.5 v. Is it same as getCurrentEvent() in SWF v2.0.5?

    Thanks
    Same problem here... I'm using Spring Web Flow 2.3.0...

    I my webflow-config.xml I have this:

    HTML Code:
      <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
    		<webflow:flow-execution-attributes>
    			<webflow:always-redirect-on-pause value="false" />
    			<!-- <webflow:redirect-in-same-state value="false"/> -->
    		</webflow:flow-execution-attributes>
    		<webflow:flow-execution-listeners>
    			<webflow:listener ref="jpaFlowExecutionListener" />
    			<webflow:listener ref="facesContextListener" />
    			<webflow:listener ref="myFlowListener" />
    		</webflow:flow-execution-listeners>
    	</webflow:flow-executor>

    myFlowListener:


    HTML Code:
    package ch.itartis.relman.web.flow.listener;
    
    import java.util.LinkedList;
    
    import org.springframework.webflow.definition.StateDefinition;
    import org.springframework.webflow.engine.ViewState;
    import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
    import org.springframework.webflow.execution.FlowSession;
    import org.springframework.webflow.execution.RequestContext;
    
    public class myFlowListener extends FlowExecutionListenerAdapter {
    
    	private String viewStatesName = "GLOBAL_BACK_LISTENER_VIEW_STATES";
    	private String backEventId = "cancel";
    
    	public void setViewStatesName(String viewStatesName) {
    		this.viewStatesName = viewStatesName;
    	}
    
    	public void setBackEventId(String backEventId) {
    		this.backEventId = backEventId;
    	}
    
    	@Override
    	public void sessionStarted(final RequestContext context, final FlowSession session) {
    		session.getScope().put(viewStatesName, new LinkedList<String>());
    	}
    
    	@Override
    	public void stateEntered(final RequestContext context, final StateDefinition previousState,
    			final StateDefinition state) {
    		if (!(previousState instanceof ViewState))
    			return;
    
    		@SuppressWarnings("unchecked")
    		final LinkedList<String> viewStates = (LinkedList<String>) context.getFlowScope().get(viewStatesName);
    
    		if (viewStates == null)
    			throw new IllegalStateException("viewStates is null");
    
    		final String previousStateId;
    
    		if (context.getCurrentEvent().getId().equals(backEventId)) {
    			viewStates.removeLast();
    			previousStateId = viewStates.getLast();
    		} else {
    			previousStateId = previousState.getId();
    			viewStates.add(previousStateId);
    		}
    
    		context.getFlowScope().put("previousViewStateId", previousStateId);
    	}
    }
    And in my mainflow, I use this as a global transition:

    HTML Code:
    <transition on="cancel" to="${flowScope.previousViewStateId}"/>
    The Exception I get:

    HTML Code:
    14:04:23.995 [http-9080-2] DEBUG o.s.webflow.engine.Transition - Executing [Transition@efff29 on = cancel, to = ${flowScope.previousViewStateId}]
    14:04:23.995 [http-9080-2] DEBUG o.s.w.engine.impl.FlowExecutionImpl - Attempting to handle [org.springframework.webflow.execution.FlowExecutionException:
    Exception thrown in state 'createContact' of flow 'main'] with root cause [java.lang.IllegalArgumentException: Cannot find state with id '${flowScope.previ
    ousViewStateId}' in flow 'main' -- Known state ids are 'array<String>['home', 'error', 'createContact', 'editContact', 'readContact', 'listContacts', 'cont
    actConfirmed', 'createAccount', 'editAccount', 'readAccount', 'listAccounts', 'accountConfirmed']']
    14:04:24.002 [http-9080-2] DEBUG o.s.w.e.s.TransitionExecutingFlowExecutionExceptionHandler - Handling flow execution exception org.springframework.webflow
    .execution.FlowExecutionException: Exception thrown in state 'createContact' of flow 'main'
    What am I doing wrong? Please help me.
    Last edited by leonardbutz; May 18th, 2011 at 09:09 AM. Reason: fixed formatting

  3. #23
    Join Date
    Sep 2011
    Posts
    1

    Default

    Quote Originally Posted by leonardbutz View Post
    Same problem here... I'm using Spring Web Flow 2.3.0...

    And in my mainflow, I use this as a global transition:

    HTML Code:
    <transition on="cancel" to="${flowScope.previousViewStateId}"/>
    What am I doing wrong? Please help me.
    I was suffering the same problem. The key seems to be the change in EL notation in 2.3.0 (and possibly earlier) to the use of #{...} instead of ${...} as delimiter markers. The 2.3.x documentation shows this. A simple change to the #{...} notation worked a charm for me.

Posting Permissions

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