From f9a91d63ecabd8a224b0dbc90500247b3ce182b2 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Fri, 11 Apr 2008 05:10:46 +0000 Subject: [PATCH] fixed mvc view scope model bug --- .../org/springframework/webflow/mvc/view/MvcView.java | 3 ++- .../webflow/test/MockRequestControlContext.java | 6 ++++++ .../springframework/webflow/mvc/view/MvcViewTests.java | 9 +++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java index 8adcac8e..a36edf44 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/MvcView.java @@ -185,7 +185,8 @@ public abstract class MvcView implements View { private Map flowScopes() { return requestContext.getConversationScope().union(requestContext.getFlowScope()).union( - requestContext.getFlashScope()).union(requestContext.getRequestScope()).asMap(); + requestContext.getViewScope()).union(requestContext.getFlashScope()).union( + requestContext.getRequestScope()).asMap(); } private void exposeBindingModel(Map model) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java index 5c946c09..810d2cfd 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockRequestControlContext.java @@ -42,6 +42,12 @@ public class MockRequestControlContext extends MockRequestContext implements Req private boolean alwaysRedirectOnPause; + /** + * Creates a new mock request control context. + */ + public MockRequestControlContext() { + } + /** * Creates a new mock request control context for controlling a mock execution of the provided flow definition. * @param flow the flow definition diff --git a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java index 13abc353..f2f4d880 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/mvc/view/MvcViewTests.java @@ -19,9 +19,12 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; import org.springframework.validation.BindingResult; import org.springframework.web.servlet.View; +import org.springframework.webflow.engine.StubViewFactory; +import org.springframework.webflow.engine.ViewState; import org.springframework.webflow.execution.RequestContext; import org.springframework.webflow.test.MockFlowExecutionKey; import org.springframework.webflow.test.MockRequestContext; +import org.springframework.webflow.test.MockRequestControlContext; public class MvcViewTests extends TestCase { @@ -38,7 +41,8 @@ public class MvcViewTests extends TestCase { } public void testRender() throws Exception { - MockRequestContext context = new MockRequestContext(); + MockRequestControlContext context = new MockRequestControlContext(); + context.setCurrentState(new ViewState(context.getRootFlow(), "test", new StubViewFactory())); context.getRequestScope().put("foo", "bar"); context.getFlowScope().put("bar", "baz"); context.getFlowScope().put("bindBean", new BindBean()); @@ -66,7 +70,8 @@ public class MvcViewTests extends TestCase { } public void testRenderWithBindingModel() throws Exception { - MockRequestContext context = new MockRequestContext(); + MockRequestControlContext context = new MockRequestControlContext(); + context.setCurrentState(new ViewState(context.getRootFlow(), "test", new StubViewFactory())); Object bindBean = new BindBean(); StaticExpression modelObject = new StaticExpression(bindBean); modelObject.setExpressionString("bindBean");