From 159cbd8403788dba41e4546e948509a8bc52e860 Mon Sep 17 00:00:00 2001 From: Jeremy Grelle Date: Tue, 9 Dec 2008 20:14:27 +0000 Subject: [PATCH] SWF-963 - Render phase ignores facesContext.responseComplete --- .../faces/webflow/FlowFacesContext.java | 17 ++++------------- .../springframework/faces/webflow/JsfView.java | 3 +++ .../faces/webflow/JsfViewTests.java | 10 ---------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java index 633094dd..eb505dff 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java @@ -46,18 +46,13 @@ import org.springframework.webflow.execution.RequestContext; /** * Custom {@link FacesContext} implementation that delegates all standard FacesContext messaging functionality to a * Spring {@link MessageSource} made accessible as part of the current Web Flow request. Additionally, it manages the - * {@code responseComplete} and {@code renderResponse} flags in flash scope so that the execution of the JSF - * {@link Lifecycle} may span multiple requests in the case of the POST+REDIRECT+GET pattern being enabled. + * {@code renderResponse} flag in flash scope so that the execution of the JSF {@link Lifecycle} may span multiple + * requests in the case of the POST+REDIRECT+GET pattern being enabled. * * @author Jeremy Grelle */ public class FlowFacesContext extends FacesContext { - /** - * The key for storing the responseComplete flag - */ - static final String RESPONSE_COMPLETE_KEY = "flowResponseComplete"; - /** * The key for storing the renderResponse flag */ @@ -204,11 +199,7 @@ public class FlowFacesContext extends FacesContext { } public boolean getResponseComplete() { - Boolean responseComplete = context.getFlashScope().getBoolean(RESPONSE_COMPLETE_KEY); - if (responseComplete == null) { - return false; - } - return responseComplete.booleanValue(); + return context.getExternalContext().isResponseComplete(); } public void renderResponse() { @@ -217,7 +208,7 @@ public class FlowFacesContext extends FacesContext { } public void responseComplete() { - context.getFlashScope().put(RESPONSE_COMPLETE_KEY, Boolean.TRUE); + context.getExternalContext().recordResponseComplete(); } // ------------------ Pass-through delegate methods ----------------------// diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java index 0543d037..03fef9aa 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfView.java @@ -87,6 +87,9 @@ public class JsfView implements View { */ public void render() throws IOException { FacesContext facesContext = FlowFacesContext.newInstance(requestContext, facesLifecycle); + if (facesContext.getResponseComplete()) { + return; + } facesContext.setViewRoot(viewRoot); try { JsfUtils.notifyBeforeListeners(PhaseId.RENDER_RESPONSE, facesLifecycle, facesContext); diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java index bb28c63e..b2117962 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewTests.java @@ -99,8 +99,6 @@ public class JsfViewTests extends TestCase { EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject())) .andStubReturn(null); - EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY), EasyMock.anyObject())) - .andStubReturn(null); EasyMock.replay(new Object[] { context, flowExecutionContext, flowMap, flashScope }); @@ -113,8 +111,6 @@ public class JsfViewTests extends TestCase { EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject())) .andStubReturn(null); - EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY), EasyMock.anyObject())) - .andStubReturn(null); EasyMock.replay(new Object[] { context, flowExecutionContext, flowMap, flashScope }); @@ -132,8 +128,6 @@ public class JsfViewTests extends TestCase { */ public final void testResume_Restored_NoEvent() { - EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY))).andStubReturn( - Boolean.FALSE); EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn( Boolean.FALSE); EasyMock.expect(flashScope.put(EasyMock.matches(ViewRootHolder.VIEW_ROOT_HOLDER_KEY), EasyMock.anyObject())) @@ -163,8 +157,6 @@ public class JsfViewTests extends TestCase { */ public final void testGetView_Restore_Ajax_NoEvent() { - EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY))).andStubReturn( - Boolean.FALSE); EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn( Boolean.FALSE); EasyMock.expect(flashScope.put(EasyMock.matches(ViewRootHolder.VIEW_ROOT_HOLDER_KEY), EasyMock.anyObject())) @@ -194,8 +186,6 @@ public class JsfViewTests extends TestCase { */ public final void testGetView_Restore_EventSignaled() { - EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RESPONSE_COMPLETE_KEY))).andStubReturn( - Boolean.FALSE); EasyMock.expect(flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn( Boolean.FALSE); EasyMock.expect(flashScope.put(EasyMock.matches(ViewRootHolder.VIEW_ROOT_HOLDER_KEY), EasyMock.anyObject()))