From 8e1aa91b40a75b95af8c7cdc9c225c134d677cb0 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 29 Feb 2012 15:36:14 -0500 Subject: [PATCH] JSF view root to survive redirect in same state For JSF 2.0.x Spring Web Flow the view root could not be preserved across redirects in the same state (e.g. following validation) because a JSF state saving listener held on to the FacesContext, which Web Flow releases before the redirect. This issue was addressed in JSF 2.1 http://java.net/jira/browse/JAVASERVERFACES-1604 which means we can allow the view root to survive the redirect. Note that the behavior can also be controlled with the redirect-in-same state flow execution attribute. Issues: SWF-1502 --- build-spring-webflow/resources/changelog.txt | 1 + .../org/springframework/faces/webflow/JsfView.java | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/build-spring-webflow/resources/changelog.txt b/build-spring-webflow/resources/changelog.txt index 195ae8f1..cc46401b 100644 --- a/build-spring-webflow/resources/changelog.txt +++ b/build-spring-webflow/resources/changelog.txt @@ -8,6 +8,7 @@ Upgrade JSF Mojarra version to 2.1.7 Modify Jsf2FlowFacesContext.isValidationFailed() to check Web Flow's MessageContext for errors Recognize class-level bean validation messages in BindingResult.getGlobalErrors() Fix "embedded" mode to be flow session local, i.e. specific to a specific flow or subflow. +Allow JSF view root to survive redirect in same state (following fix in JSF Mojarra 2.1) Changes in version 2.3.0.RELEASE (Feb 28, 2011) ----------------------------------------------- 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 d270b2c0..4ff32a98 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 @@ -16,7 +16,6 @@ package org.springframework.faces.webflow; import static org.springframework.faces.webflow.JsfRuntimeInformation.isAtLeastJsf12; -import static org.springframework.faces.webflow.JsfRuntimeInformation.isLessThanJsf20; import java.io.IOException; import java.io.Serializable; @@ -137,17 +136,8 @@ public class JsfView implements View { } public Serializable getUserEventState() { - if (isLessThanJsf20()) { - // Set the temporary UIViewRoot state so that it will be available across the redirect - return new ViewRootHolder(getViewRoot()); - } else { - // In JSF 2 the partial state saving algorithm attaches a system event listener to the UIViewRoot which - // holds on to a reference to the FacesContext instance. The FacesContext instance is released at end of - // each request. Hence, keeping the UIViewRoot across the redirect is not feasible. - // @see com.sun.faces.context.StateContext$AddRemoveListener - logger.debug("User event state requested but not saved."); - return null; - } + // Set the temporary UIViewRoot state so that it will be available across the redirect + return new ViewRootHolder(getViewRoot()); } public boolean hasFlowEvent() {