From 6697fb05a1689a1b2b38bd920d33b535d945abd3 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Mon, 6 Apr 2009 22:25:50 +0000 Subject: [PATCH] polish --- .../webflow/context/ExternalContext.java | 2 +- .../context/portlet/PortletExternalContext.java | 4 ++-- .../context/servlet/ServletExternalContext.java | 4 ++-- .../webflow/engine/ViewState.java | 17 +++++++++++------ .../webflow/test/MockExternalContext.java | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java index ada58225..01648e3e 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java @@ -207,6 +207,6 @@ public interface ExternalContext { * @see #requestFlowDefinitionRedirect(String, MutableAttributeMap) * @see #requestExternalRedirect(String) */ - public boolean isRedirectRequested(); + public boolean isRedirectResponseComplete(); } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java index af16eaea..c931cbcd 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java @@ -252,7 +252,7 @@ public class PortletExternalContext implements ExternalContext { } public void requestRedirectInPopup() throws IllegalStateException { - if (isRedirectRequested()) { + if (isRedirectResponseComplete()) { redirectInPopup = true; } else { throw new IllegalStateException( @@ -260,7 +260,7 @@ public class PortletExternalContext implements ExternalContext { } } - public boolean isRedirectRequested() { + public boolean isRedirectResponseComplete() { return getFlowExecutionRedirectRequested() || getFlowDefinitionRedirectRequested() || getExternalRedirectRequested(); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java index c660d400..c2c5cee3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java @@ -248,7 +248,7 @@ public class ServletExternalContext implements ExternalContext { } public void requestRedirectInPopup() throws IllegalStateException { - if (isRedirectRequested()) { + if (isRedirectResponseComplete()) { redirectInPopup = true; } else { throw new IllegalStateException( @@ -256,7 +256,7 @@ public class ServletExternalContext implements ExternalContext { } } - public boolean isRedirectRequested() { + public boolean isRedirectResponseComplete() { return getFlowExecutionRedirectRequested() || getFlowDefinitionRedirectRequested() || getExternalRedirectRequested(); } 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 e3e89706..862cff46 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 @@ -171,7 +171,7 @@ public class ViewState extends TransitionableState { context.assignFlowExecutionKey(); ExternalContext externalContext = context.getExternalContext(); if (externalContext.isResponseComplete()) { - clearFlashIfRenderResponse(context); + clearFlashIfNotRedirecting(context); } else { if (shouldRedirect(context)) { context.getExternalContext().requestFlowExecutionRedirect(); @@ -182,6 +182,8 @@ public class ViewState extends TransitionableState { if (externalContext.isResponseAllowed()) { View view = viewFactory.getView(context); render(context, view); + } else { + externalContext.recordResponseComplete(); } } } @@ -200,7 +202,7 @@ public class ViewState extends TransitionableState { if (!stateExited) { ExternalContext externalContext = context.getExternalContext(); if (externalContext.isResponseComplete()) { - clearFlashIfRenderResponse(context); + clearFlashIfNotRedirecting(context); } else { if (externalContext.isAjaxRequest()) { renderIfAllowed(context, view); @@ -216,7 +218,7 @@ public class ViewState extends TransitionableState { } else { ExternalContext externalContext = context.getExternalContext(); if (externalContext.isResponseComplete()) { - clearFlashIfRenderResponse(context); + clearFlashIfNotRedirecting(context); } else { renderIfAllowed(context, view); } @@ -251,8 +253,11 @@ public class ViewState extends TransitionableState { } private void renderIfAllowed(RequestControlContext context, View view) throws ViewRenderingException { - if (context.getExternalContext().isResponseAllowed()) { + ExternalContext externalContext = context.getExternalContext(); + if (externalContext.isResponseAllowed()) { render(context, view); + } else { + externalContext.recordResponseComplete(); } } @@ -274,8 +279,8 @@ public class ViewState extends TransitionableState { context.viewRendered(view); } - private void clearFlashIfRenderResponse(RequestContext context) { - if (context.getExternalContext().isResponseAllowed() && !context.getExternalContext().isRedirectRequested()) { + private void clearFlashIfNotRedirecting(RequestContext context) { + if (!context.getExternalContext().isRedirectResponseComplete()) { clearFlash(context); } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java index 0dd55f04..fc6a3c90 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java @@ -183,7 +183,7 @@ public class MockExternalContext implements ExternalContext { } public void requestRedirectInPopup() throws IllegalStateException { - if (isRedirectRequested()) { + if (isRedirectResponseComplete()) { redirectInPopup = true; } else { throw new IllegalStateException( @@ -191,7 +191,7 @@ public class MockExternalContext implements ExternalContext { } } - public boolean isRedirectRequested() { + public boolean isRedirectResponseComplete() { return getFlowExecutionRedirectRequested() || getFlowDefinitionRedirectRequested() || getExternalRedirectRequested(); }