You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2014/08/06 23:01:35 UTC
svn commit: r1616348 - in /myfaces/core/trunk:
impl/src/main/java/org/apache/myfaces/renderkit/
shared/src/main/java/org/apache/myfaces/shared/config/
shared/src/main/java/org/apache/myfaces/shared/context/flash/
Author: lu4242
Date: Wed Aug 6 21:01:34 2014
New Revision: 1616348
URL: http://svn.apache.org/r1616348
Log:
MYFACES-3891 Don't write flash-scoped variables in ErrorPageWriter when FLASH_SCOPE_DISABLED=true (Thanks to Martin Kočí for provide this patch)
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java
myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java?rev=1616348&r1=1616347&r2=1616348&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/ErrorPageWriter.java Wed Aug 6 21:01:34 2014
@@ -70,6 +70,7 @@ import javax.servlet.http.HttpServletRes
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
import org.apache.myfaces.lifecycle.ViewNotFoundException;
+import org.apache.myfaces.shared.config.MyfacesConfig;
import org.apache.myfaces.shared.renderkit.html.HtmlResponseWriterImpl;
import org.apache.myfaces.shared.util.ClassUtils;
import org.apache.myfaces.shared.util.StateUtils;
@@ -772,7 +773,11 @@ public final class ErrorPageWriter
{
_writeVariables(writer, ctx.getSessionMap(), "Session Attributes");
}
- _writeVariables(writer, ctx.getFlash(), "Flash Attributes");
+ MyfacesConfig config = MyfacesConfig.getCurrentInstance(ctx);
+ if(config!=null && !config.isFlashScopeDisabled() && ctx.getFlash() != null)
+ {
+ _writeVariables(writer, ctx.getFlash(), "Flash Attributes");
+ }
_writeVariables(writer, ctx.getApplicationMap(), "Application Attributes");
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java?rev=1616348&r1=1616347&r2=1616348&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/config/MyfacesConfig.java Wed Aug 6 21:01:34 2014
@@ -466,6 +466,15 @@ public class MyfacesConfig
public static final String INIT_PARAM_RENDER_FORM_VIEW_STATE_AT_BEGIN =
"org.apache.myfaces.RENDER_FORM_VIEW_STATE_AT_BEGIN";
public final static boolean INIT_PARAM_RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT = false;
+
+ /**
+ * Defines whether flash scope is disabled, preventing add the Flash cookie to the response.
+ *
+ * <p>This is useful for applications that does not require to use flash scope, and instead uses other scopes.</p>
+ */
+ @JSFWebConfigParam(defaultValue="false",since="2.0.5")
+ public static final String INIT_PARAM_FLASH_SCOPE_DISABLED = "org.apache.myfaces.FLASH_SCOPE_DISABLED";
+ public static final boolean INIT_PARAM_FLASH_SCOPE_DISABLED_DEFAULT = false;
private boolean _prettyHtml;
private boolean _detectJavascript;
@@ -504,6 +513,7 @@ public class MyfacesConfig
private boolean _cdiManagedValidatorsEnabled;
private boolean _strictJsf2FaceletsCompatibility;
private boolean _renderFormViewStateAtBegin;
+ private boolean _flashScopeDisabled;
private static final boolean TOMAHAWK_AVAILABLE;
private static final boolean MYFACES_IMPL_AVAILABLE;
@@ -610,6 +620,7 @@ public class MyfacesConfig
setCdiManagedValidatorsEnabled(INIT_PARAM_CDI_MANAGED_VALIDATORS_DEFAULT);
setStrictJsf2FaceletsCompatibility(INIT_PARAM_STRICT_JSF_2_FACELETS_COMPATIBILITY_DEFAULT);
setRenderFormViewStateAtBegin(INIT_PARAM_RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT);
+ setFlashScopeDisabled(INIT_PARAM_FLASH_SCOPE_DISABLED_DEFAULT);
}
private static MyfacesConfig createAndInitializeMyFacesConfig(ExternalContext extCtx)
@@ -736,6 +747,10 @@ public class MyfacesConfig
INIT_PARAM_RENDER_FORM_VIEW_STATE_AT_BEGIN,
INIT_PARAM_RENDER_FORM_VIEW_STATE_AT_BEGIN_DEFAULT));
+ myfacesConfig.setFlashScopeDisabled(WebConfigParamUtils.getBooleanInitParameter(extCtx,
+ INIT_PARAM_FLASH_SCOPE_DISABLED,
+ INIT_PARAM_FLASH_SCOPE_DISABLED_DEFAULT));
+
if (TOMAHAWK_AVAILABLE)
{
myfacesConfig.setDetectJavascript(getBooleanInitParameter(extCtx, INIT_PARAM_DETECT_JAVASCRIPT,
@@ -1313,4 +1328,14 @@ public class MyfacesConfig
{
this._renderFormViewStateAtBegin = renderFormViewStateAtBegin;
}
+
+ public boolean isFlashScopeDisabled()
+ {
+ return _flashScopeDisabled;
+ }
+
+ public void setFlashScopeDisabled(boolean flashScopeDisabled)
+ {
+ this._flashScopeDisabled = flashScopeDisabled;
+ }
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java?rev=1616348&r1=1616347&r2=1616348&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java Wed Aug 6 21:01:34 2014
@@ -19,7 +19,6 @@
package org.apache.myfaces.shared.context.flash;
import org.apache.myfaces.shared.util.SubKeyMap;
-import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFWebConfigParam;
import org.apache.myfaces.shared.util.ExternalContextUtils;
import javax.faces.application.FacesMessage;
@@ -46,6 +45,7 @@ import javax.faces.event.PostPutFlashVal
import javax.faces.event.PreClearFlashEvent;
import javax.faces.event.PreRemoveFlashValueEvent;
import javax.faces.lifecycle.ClientWindow;
+import org.apache.myfaces.shared.config.MyfacesConfig;
/**
* Implementation of Flash object
@@ -58,14 +58,6 @@ public class FlashImpl extends Flash
private static final Logger log = Logger.getLogger(FlashImpl.class.getName());
/**
- * Defines whether flash scope is disabled, preventing add the Flash cookie to the response.
- *
- * <p>This is useful for applications that does not require to use flash scope, and instead uses other scopes.</p>
- */
- @JSFWebConfigParam(defaultValue="false",since="2.0.5")
- private static final String FLASH_SCOPE_DISABLED_PARAM = "org.apache.myfaces.FLASH_SCOPE_DISABLED";
-
- /**
* Use this prefix instead of the whole class name, because
* this makes the Cookies and the SubKeyMap operations (actually
* every String based operation where this is used as a key) faster.
@@ -203,7 +195,7 @@ public class FlashImpl extends Flash
_count = new AtomicLong(_getSeed());
// Read whether flash scope is disabled.
- _flashScopeDisabled = "true".equalsIgnoreCase(externalContext.getInitParameter(FLASH_SCOPE_DISABLED_PARAM));
+ _flashScopeDisabled = MyfacesConfig.getCurrentInstance(externalContext).isFlashScopeDisabled();
}
// ~ methods from javax.faces.context.Flash -------------------------------
@@ -1115,7 +1107,7 @@ public class FlashImpl extends Flash
if (_flashScopeDisabled)
{
throw new FlashScopeDisabledException("Flash scope was disabled by context param "
- + FLASH_SCOPE_DISABLED_PARAM + " but erroneously accessed");
+ + MyfacesConfig.INIT_PARAM_FLASH_SCOPE_DISABLED + " but erroneously accessed");
}
}