From 2b224c68cdad34038baeaa151832624261e2cce3 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Tue, 10 Mar 2009 04:24:56 +0000 Subject: [PATCH] swf-1041 --- .../webflow/engine/ViewState.java | 7 +++++-- .../webflow/engine/ViewStateTests.java | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java index df2d5b8d..cab244ca 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/ViewState.java @@ -190,13 +190,16 @@ public class ViewState extends TransitionableState { if (logger.isDebugEnabled()) { logger.debug("Event '" + event.getId() + "' returned from view " + view); } - context.getRequestScope().put("webflow.originatingViewState", this); boolean stateExited = context.handleEvent(event); if (!stateExited && context.getExternalContext().isResponseAllowed()) { if (context.getExternalContext().isAjaxRequest()) { render(context, view); } else { - context.getExternalContext().requestFlowExecutionRedirect(); + if (shouldRedirect(context)) { + context.getExternalContext().requestFlowExecutionRedirect(); + } else { + render(context, view); + } } } } else { diff --git a/spring-webflow/src/test/java/org/springframework/webflow/engine/ViewStateTests.java b/spring-webflow/src/test/java/org/springframework/webflow/engine/ViewStateTests.java index 2336e345..b225722e 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/engine/ViewStateTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/engine/ViewStateTests.java @@ -183,6 +183,26 @@ public class ViewStateTests extends TestCase { state.resume(context); assertTrue(context.getFlowExecutionContext().isActive()); assertEquals(1, action.getExecutionCount()); + assertFalse(context.getMockExternalContext().getFlowExecutionRedirectRequested()); + } + + public void testResumeViewStateForEventStateNotExitedNonAjaxRedirectEnabled() { + Flow flow = new Flow("myFlow"); + StubViewFactory viewFactory = new StubViewFactory(); + ViewState state = new ViewState(flow, "viewState", viewFactory); + Transition t = new Transition(on("submit"), null); + TestAction action = new TestAction(); + t.setExecutionCriteria(new ActionTransitionCriteria(action)); + state.getTransitionSet().add(t); + MockRequestControlContext context = new MockRequestControlContext(flow); + context.setAlwaysRedirectOnPause(true); + state.enter(context); + context = new MockRequestControlContext(context.getFlowExecutionContext()); + context.setAlwaysRedirectOnPause(true); + context.putRequestParameter("_eventId", "submit"); + state.resume(context); + assertTrue(context.getFlowExecutionContext().isActive()); + assertEquals(1, action.getExecutionCount()); assertTrue(context.getMockExternalContext().getFlowExecutionRedirectRequested()); }