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
This commit is contained in:
Rossen Stoyanchev
2012-02-29 15:36:14 -05:00
parent 63151acb8d
commit 8e1aa91b40
2 changed files with 3 additions and 12 deletions

View File

@@ -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)
-----------------------------------------------

View File

@@ -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() {