incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r479698 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: renderkit/core/xhtml/StyleSheetRenderer.java renderkit/core/xhtml/XhtmlUtils.java ui/laf/base/xhtml/XhtmlLafUtils.java
Date Mon, 27 Nov 2006 17:34:35 GMT
Author: jwaldman
Date: Mon Nov 27 09:34:34 2006
New Revision: 479698

URL: http://svn.apache.org/viewvc?view=rev&rev=479698
Log:
Add XhtmlUtils.isDisableContentCompression hook so that we can also look at the output-mode
for 'portlet' when deciding whether to disable content compression.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java?view=diff&rev=479698&r1=479697&r2=479698
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java
Mon Nov 27 09:34:34 2006
@@ -29,6 +29,7 @@
 import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderingContext;
 
+import org.apache.myfaces.trinidadinternal.share.config.Configuration;
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
 import org.apache.myfaces.trinidadinternal.style.StyleProvider;
 import org.apache.myfaces.trinidadinternal.style.util.StyleUtils;
@@ -41,20 +42,6 @@
  */
 public class StyleSheetRenderer extends XhtmlRenderer
 { 
-  /**
-   * Disables optimizations that are normally performed by the
-   * Trinidad Renderers to reduce content size.
-   * <p>
-   * This Boolean property controls whether or not Trinidad Renderer
-   * implementations should attempt to reduce the size of generated
-   * content, for example, by compressing style class names.  These
-   * optimizations are enabled by default.  In general,
-   * clients should not need to disable these optimizations.  However,
-   * clients that want to disable this functionality for testing or
-   * debugging purposes can do so by setting this property to Boolean.TRUE.
-   */
-  static public final String DISABLE_CONTENT_COMPRESSION =
-    "org.apache.myfaces.trinidadinternal.DISABLE_CONTENT_COMPRESSION";
 
   public StyleSheetRenderer()
   {
@@ -135,9 +122,7 @@
       // Hand the Faces-major renderers the style Map for compressing.
       // Oddly enough, this code has to be after provider.getStyleSheetURI(),
       // because that call boostraps up the style provider in general.
-      if (!"true".equals(
-          context.getExternalContext().getInitParameter(
-                                 DISABLE_CONTENT_COMPRESSION)))
+      if (!XhtmlUtils.isDisableContentCompression(context, arc))
       {
         if (arc instanceof CoreRenderingContext)
         {

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java?view=diff&rev=479698&r1=479697&r2=479698
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlUtils.java
Mon Nov 27 09:34:34 2006
@@ -39,9 +39,11 @@
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
 import org.apache.myfaces.trinidad.context.RenderingContext;
 
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.jsLibs.Scriptlet;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.jsLibs.XhtmlScriptletFactory;
 
+import org.apache.myfaces.trinidadinternal.share.config.Configuration;
 import org.apache.myfaces.trinidadinternal.share.util.FastMessageFormat;
 
 
@@ -84,6 +86,39 @@
             Boolean.TRUE.equals(
              agent.getCapabilities().get(TrinidadAgent.CAP_PARTIAL_RENDERING)));
   }
+  
+  /**
+   * Return true if we should disable content compression
+   * @param fContext FacesContext
+   * @param renderingContext RenderingContext, where we can get the outputMode.
+   * @return true if we should disable content compression. If in a portlet, then we want
to
+   * disable content compression.
+   */
+  static public boolean isDisableContentCompression(
+    FacesContext     fContext,
+    RenderingContext renderingContext)
+  {    
+    String outputMode = renderingContext.getOutputMode();
+    return _isDisableContentCompression(fContext, outputMode);
+  }
+  
+  /**
+   * Return true if we should disable content compression
+   * @param fContext FacesContext
+   * @param requestContext RequestContext, where we can get the outputMode.
+   * @return true if we should disable content compression. If in a portlet, then we want
to
+   * disable content compression.
+   */
+  static public boolean isDisableContentCompression(
+    FacesContext   fContext,
+    RequestContext requestContext)
+  {
+    String outputMode = requestContext.getOutputMode();
+    return _isDisableContentCompression(fContext, outputMode);
+  }
+
+  
+
 
   /** Library key for the locale lib */
   public static final String CORE_LIB =
@@ -502,6 +537,25 @@
   {
     FastMessageFormat formatter = new FastMessageFormat(pattern);
     return formatter.format(parameters);
+  }
+  
+  
+  /**
+   * Return true if we should disable content compression. It looks at both the disable
+   * content compression init parameter and the outputMode.
+   * @param fContext
+   * @param outputMode String. We compare this against XhtmlConstants.OUTPUT_MODE_PORTLET
+   * @return
+   */
+  static private boolean _isDisableContentCompression(
+    FacesContext fContext,
+    String       outputMode)
+  {
+    String disableContentCompressionParam =
+      fContext.getExternalContext().getInitParameter(Configuration.DISABLE_CONTENT_COMPRESSION);
+    return ("true".equals(disableContentCompressionParam) || 
+            XhtmlConstants.OUTPUT_MODE_PORTLET.equals(outputMode));
+
   }
 
   /** HashMap mapping names to their scriptlets */

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java?view=diff&rev=479698&r1=479697&r2=479698
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/ui/laf/base/xhtml/XhtmlLafUtils.java
Mon Nov 27 09:34:34 2006
@@ -29,6 +29,7 @@
 import javax.faces.context.ResponseWriter;
 
 import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.skin.Icon;
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
@@ -310,12 +311,9 @@
     // try to get it now
     if (styleClasses == null)
     {
-      ExternalContext external =
-        context.getFacesContext().getExternalContext();
+      if (!(XhtmlUtils.isDisableContentCompression(context.getFacesContext(), 
+          RequestContext.getCurrentInstance())))
 
-      if (!"true".equals(
-           external.getInitParameter(
-             Configuration.DISABLE_CONTENT_COMPRESSION)))
       {
         StyleContext styleContext = context.getStyleContext();
         StyleProvider provider = context.getStyleContext().getStyleProvider();



Mime
View raw message