From 0636499121e72366a9e429d6af07af3664eb1a9b Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 22 May 2014 14:23:05 -0400 Subject: [PATCH] Move state saving to getUserEventState() Update JsfView so that state saving no longer occurs during processUserEvent(). This is required to ensure that Mojarra's StateContext.release(...) method is not called too early. Prior to Mojarra 2.1.16 multiple calls to saveView had no side effects, but the fix to JAVASERVERFACES-2609 changed this behavior. In order to retain the fix for SWF-1577 the saveState() method is now called from getUserEventState(). This should ensure that the StateContext$AddRemoveListerner is still removed, even when WebFlow bypasses the usual state saving for certain flow redirects. Issue: SWF-1631 --- gradle.properties | 2 +- .../org/springframework/faces/webflow/JsfView.java | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 547ac429..0c21637e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=2.3.3.BUILD-SNAPSHOT +version=2.3.4.BUILD-SNAPSHOT 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 2e4ab3de..01a52c6a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2004-2013 the original author or authors. + * Copyright 2004-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,13 +87,6 @@ public class JsfView implements View { try { logger.debug("Asking faces lifecycle to render"); facesLifecycle.render(facesContext); - - /* Ensure serialized view state is always updated even if JSF didn't call StateManager.writeState(). */ - if (JsfRuntimeInformation.isAtLeastJsf20()) { - if (requestContext.getExternalContext().isAjaxRequest()) { - saveState(); - } - } } finally { logger.debug("View rendering complete"); facesContext.responseComplete(); @@ -141,6 +134,10 @@ public class JsfView implements View { public Serializable getUserEventState() { // Set the temporary UIViewRoot state so that it will be available across the redirect + + // Ensure serialized view state is always updated even if JSF didn't call StateManager.writeState(). SWF-1577 + saveState(); + return new ViewRootHolder(getViewRoot()); }