Announcement Announcement Module
Collapse
No announcement yet.
How to configure a global transition for a back button? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by klr8 View Post
    Are you sure about that? I tried to reproduce this and for me (with SWF 1.0.1) it's working correctly.

    Erwin
    Hi Erwin,
    I'm also using SWF 1.0.1 , spring 2.0.2 .

    The stateEntered() method fires twice on entry to the subflow: once on entry to the subflow-state within the application-flow, and again on entry to the first view-state in the subflow "cancel-flow".

    My config is only slightly different to that described in my previous post: my cancel-flow is a top level flow rather than inline.

    To the stateEntered() method of the listener, I temporarily added:
    Code:
    System.out.println(state.getId() + ":" + state.getOwner().getId())
    On firing the "cancel" event from within my application-flow , the following standard output is produced:

    Code:
    08:19:36,459 INFO  [STDOUT] confirmCancel:application-flow
    08:19:47,881 INFO  [STDOUT] promptConfirmCancel:cancel-flow
    My listener is configured to listen to the application-flow, not the cancel-flow, as seen in my previous post.

    Comment


    • #17
      The stateEntered() method fires twice on entry to the subflow: once on entry to the subflow-state within the application-flow, and again on entry to the first view-state in the subflow "cancel-flow".
      This is normal. The Listeners are attached to the flow execution when it launches. So they take the top level flow into account to determine whether or not to attach. When you enter the subflow, the listener is already attached and that remains the case. As a result it is also fired from inside the subflow.

      This is currently the intended behaviour: the FlowExecutionListener observes a FlowExecution, not a Flow. A FlowExecution might involve multiple Flows (parent, sub).

      Erwin

      Comment


      • #18
        Thanks for the clarification.

        Comment


        • #19
          About this, the code shown here would work on SWF 2.0.3 as well ?

          I really have serious doubts about it, but if it works it would fit nicely in my project,


          Best Regards.

          Comment


          • #20
            compile error at context.getLastEvent()

            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
            Last edited by Rajendra; Feb 3rd, 2009, 02:54 AM.

            Comment


            • #21
              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

              Comment


              • #22
                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, 09:09 AM. Reason: fixed formatting

                Comment


                • #23
                  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.

                  Comment

                  Working...
                  X