From c9179d9d21f97db418abb893e9a22892c7578c2c Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Mon, 5 May 2008 16:19:51 +0000 Subject: [PATCH] fixed environmental bug for portlet fixed issue preventing rendering of views otuside of view states --- .../faces/webflow/FlowViewStateManager.java | 4 ++++ .../webflow/mvc/builder/MvcEnvironment.java | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewStateManager.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewStateManager.java index 20de8ef1..d354043f 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewStateManager.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowViewStateManager.java @@ -85,6 +85,10 @@ public class FlowViewStateManager extends StateManager { return super.restoreTreeStructure(context, viewId, renderKitId); } RequestContext requestContext = RequestContextHolder.getRequestContext(); + if (!requestContext.inViewState()) { + logger.debug("Not in a view state; no state to restore"); + return null; + } SerializedView view = (SerializedView) requestContext.getViewScope().get(SERIALIZED_VIEW_STATE); if (view == null || !view.viewId.equals(viewId)) { logger.debug("No matching view in view scope"); diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcEnvironment.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcEnvironment.java index 8bbacc07..09e221f4 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcEnvironment.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/builder/MvcEnvironment.java @@ -48,8 +48,7 @@ public class MvcEnvironment extends StaticLabeledEnum { * @return the web environment the context is running in, or null if not running in a web environment */ public static MvcEnvironment environmentFor(ApplicationContext applicationContext) { - if (ClassUtils.isPresent("javax.portlet.PortletContext") - && applicationContext instanceof ConfigurablePortletApplicationContext) { + if (ClassUtils.isPresent("javax.portlet.PortletContext") && isPortletApplicationContext(applicationContext)) { return MvcEnvironment.PORTLET; } else if (applicationContext instanceof WebApplicationContext) { return MvcEnvironment.SERVLET; @@ -58,4 +57,9 @@ public class MvcEnvironment extends StaticLabeledEnum { } } + private static boolean isPortletApplicationContext(ApplicationContext applicationContext) { + return ClassUtils.isPresent("org.springframework.web.portlet.context.ConfigurablePortletApplicationContext") + && applicationContext instanceof ConfigurablePortletApplicationContext; + } + }