You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2009/01/05 22:57:59 UTC

svn commit: r731738 - in /myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main: java/org/apache/myfaces/trinidadinternal/renderkit/core/ java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ java/org/apache/myfaces/trinidadinternal/skin/ java/o...

Author: jwaldman
Date: Mon Jan  5 13:57:59 2009
New Revision: 731738

URL: http://svn.apache.org/viewvc?rev=731738&view=rev
Log:
TRINIDAD-1358 if there is a skin [stylesheet] id mismatch between producer and consumer, use the skin anyway instead of the portlet skin

Modified:
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
    myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java?rev=731738&r1=731737&r2=731738&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderingContext.java Mon Jan  5 13:57:59 2009
@@ -401,21 +401,25 @@
 
   /**
    * Returns the skin that is requested on the request map if the exact skin exists.
+   * This only does something if the outputMode is portlet. Otherwise it returns null.
    * <p>
    * If we are in a portlet, then we might need to recalculate the skin.
-   * The portal container might have its own skin that it wants us to use instead
+   * The portal container might have its own skin that it wants us (the producer) to use instead
    * of what we picked based on the skin-family and render-kit-id.
    * If it does, it will send the skin-id and the skin's styleSheetDocument id
    * in the request map.
    * </p>
    * <p>
    * If we have the skin with that id and the stylesheetdocument's id match,
-   * then we return that skin; else we return null, indicating that there is no
-   * requestMap skin.
+   * then we return that skin (but we won't compress the style classes so they won't clash with the
+   * consumer's style classes which should be compressed). If we have the skin but the
+   * stylesheetdocument ids do not match, we still return that skin;
+   * else we return null, indicating that there is no requestMap skin that exists.
+   *
    * </p>
    * @return null if there is no local skin that matches the requestMap skin, if any.
    *         skin that is requested to be used on the requestMap if we can find that
-   *         exact skin with the same stylesheetdocument id locally.
+   *         exact skin.
    */
   public Skin getRequestMapSkin()
   {
@@ -435,6 +439,7 @@
       Object requestedSkinId = requestMap.get(_SKIN_ID_PARAM);
       if (requestedSkinId != null)
       {
+
         SkinFactory factory = SkinFactory.getFactory();
         if (factory == null)
         {
@@ -445,53 +450,91 @@
         Skin requestedSkin = factory.getSkin(context, requestedSkinId.toString());
         if (requestedSkin != null)
         {
-          // Get the skin's stylesheet id from the request Map and then compare it
-          // to the local skin's stylesheet id to make sure they match.
+          // In portlet mode, we will switch to using the requestedSkin
+          // (the skin requested by the portlet's producer on the requestMap) if it exists.
+          // Otherwise we'll use the portal skin.
+          if (_LOG.isFine())
+            _LOG.fine("The skin " +requestedSkinId+ " specified on the requestMap will be used.");
+          _requestMapSkin = requestedSkin;
+
+          // Check here if the stylesheet ids match. This method logs a warning if we cannot
+          // share the skin stylesheet between producer and consumer.
+          isRequestMapStyleSheetIdAndSkinEqual(context, requestedSkin);
+
+          // wrap in the RequestSkinWrapper, else we get property/icon
+          // not found errors
+          return new RequestSkinWrapper(requestedSkin);
+          // todo Should I wrap it in something that says that we don't need to compress. In FileSystemStyleCache,
+          // we could look to see what kind of skin it is??? Portal skins have a styleClassMap, but they
+          // do not want compression.
+
+        }// end requestedSkin != null
+        else
+        {
+          if (_LOG.isWarning())
+          {
+            _LOG.warning("REQUESTMAP_SKIN_NOT_USED_BECAUSE_NOT_EXIST",requestedSkinId);
+          }
+        }
+      }
+
+    } // end outputMode == portlet
+    return null;
+  }
+
+  /**
+   * This helps figure out if the portlet producer can share the portlet consumer's stylesheet.
+   * @param context
+   * @param requestedSkin The skin that the portlet consumer wants the producer to share.
+   * @return true if the skin stylesheet id parameter on the request map is equal to
+                  the requestedSkin's stylesheetId.
+   */
+  public boolean isRequestMapStyleSheetIdAndSkinEqual(
+    FacesContext context,
+    Skin         requestedSkin)
+  {
+    if (CoreRenderKit.OUTPUT_MODE_PORTLET.equals(getOutputMode()))
+    {
+      // check the stylesheetids for a match.
+      if (_styleSheetDocumentIdMatch == null)
+      {
+        // first default to false and override later on if the stylesheetids match.
+        _styleSheetDocumentIdMatch = Boolean.FALSE;
+        if (requestedSkin != null)
+        {
+          Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
           Object requestMapStyleSheetId = requestMap.get(_SKIN_STYLESHEET_ID_PARAM);
+
           if (requestMapStyleSheetId != null)
           {
-            // set up the styleProvider first, so that it will create the /adf/style
-            // directory. Otherwise the following code would get an error when it
-            // tries to getStyleDir. This could possibly be done better.
-            getStyleContext().getStyleProvider();
-
             String skinForPortalStyleSheetId = requestedSkin.getStyleSheetDocumentId(this);
             if (skinForPortalStyleSheetId != null &&
-                skinForPortalStyleSheetId.equals(requestMapStyleSheetId))
+              skinForPortalStyleSheetId.equals(requestMapStyleSheetId))
             {
-              // it is ok to use this skin
-              // Switch the _skin here to be the tmpRequestedSkin
-              if (_LOG.isFine())
-                _LOG.fine("The skin " +requestedSkinId+
-                  " specified on the requestMap will be used.");
-              _requestMapSkin = requestedSkin;
-              // wrap in the RequestSkinWrapper, else we get property/icon
-              // not found errors
-              return new RequestSkinWrapper(requestedSkin);
+              _styleSheetDocumentIdMatch = Boolean.TRUE;
             }
             else
             {
               if (_LOG.isWarning())
-                _LOG.warning("REQUESTMAP_SKIN_NOT_USED_BECAUSE_STYLESHEETDOCUMENT_ID_NOT_MATCH_LOCAL_SKIN",requestedSkinId);
+              {
+                _LOG.warning("STYLESHEETDOCUMENT_ID_NOT_MATCH_LOCAL_SKIN", requestedSkin.getId());
+              }
             }
           }
           else
           {
-            if (_LOG.isSevere())
-              _LOG.severe("REQUESTMAP_SKIN_NOT_USED_BECAUSE_STYLESHEETDOCUMENT_ID_NOT_IN_REQUESTMAP",requestedSkinId);
-          }
-        }// end requestedSkin != null
-        else
-        {
-          if (_LOG.isWarning())
-          {
-            _LOG.warning("REQUESTMAP_SKIN_NOT_USED_BECAUSE_NOT_EXIST",requestedSkinId);
+            if (_LOG.isWarning())
+            {
+              _LOG.warning("STYLESHEETDOCUMENT_ID_NOT_IN_REQUESTMAP", requestedSkin.getId());
+            }
           }
         }
+
       }
+      return Boolean.TRUE.equals(_styleSheetDocumentIdMatch);
+    }
 
-    } // end outputMode == portlet
-    return null;
+    return false;
   }
 
   /**
@@ -682,6 +725,7 @@
   private Skin                _skin;
   private boolean             _checkedRequestMapSkin = false;
   private Skin                _requestMapSkin;
+  private Object              _styleSheetDocumentIdMatch;
   private FormData            _formData;
   private TrinidadAgent       _agent;
   private Map<String, String> _styleMap;

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java?rev=731738&r1=731737&r2=731738&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java Mon Jan  5 13:57:59 2009
@@ -32,6 +32,7 @@
 import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.HtmlRenderer;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.StyleSheetRenderer;
 import org.apache.myfaces.trinidadinternal.share.config.Configuration;
 import org.apache.myfaces.trinidadinternal.skin.SkinStyleProvider;
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
@@ -69,7 +70,12 @@
   public StyleProvider getStyleProvider(boolean recompute)
   {
     if (recompute)
+    {
       _styleProvider = null;
+      _isDisableStyleCompression = null;
+      // recalculate in case the skin switched in the portlet case
+      isDisableStyleCompression();
+    }
     
     return getStyleProvider();
   }
@@ -145,6 +151,63 @@
   {
     return CoreRenderKit.OUTPUT_MODE_PORTLET.equals(_arc.getOutputMode());
   }
+  
+  /**
+   *
+   * @return true if we should disable style compression. e.g., 
+   * if StyleSheetRenderer.DISABLE_CONTENT_COMPRESSION is true or the skin is a portlet skin
+   * or we are in portlet mode and not doing skin sharing.
+   */
+  public boolean isDisableStyleCompression()
+  {
+    if (_isDisableStyleCompression == null)
+    {
+      FacesContext context = FacesContext.getCurrentInstance();
+      String disableContentCompression =
+        context.getExternalContext().
+        getInitParameter(StyleSheetRenderer.DISABLE_CONTENT_COMPRESSION);
+      boolean disableContentCompressionBoolean = "true".equals(disableContentCompression);
+      
+      // the user wants to explicitly disable the content compression and show the full styleclass
+      // names
+      if (disableContentCompressionBoolean)
+        _isDisableStyleCompression = Boolean.TRUE;
+      
+      // we still need to check if we don't want to compress even if the disable content 
+      // compression flag is true
+      if (CoreRenderKit.OUTPUT_MODE_PORTLET.equals(_arc.getOutputMode()))
+      {
+        Skin skin = ((CoreRenderingContext) _arc).getSkin();
+        boolean isPortletSkin =
+        CoreRenderKit.OUTPUT_MODE_PORTLET.equals(skin.getRenderKitId());
+
+        if (isPortletSkin)
+          _isDisableStyleCompression = Boolean.TRUE;
+        else
+        {
+          // we must be skin sharing. Check if the stylesheetids of the producer and consumer skin
+          // match.
+          // if so then we do whatever the disableContentCompression says to do.
+          // if not, we must not compress so that we don't have conflicts with the producer
+          // stylesheet which does compress.
+
+          if (!(((CoreRenderingContext) _arc).
+            isRequestMapStyleSheetIdAndSkinEqual(context, skin)))
+          {
+            _isDisableStyleCompression = Boolean.TRUE;
+          }
+        }
+      }
+    }
+    // if _isDisableStyleCompression is still null, 
+    // default it to false since disabling styling compression defaults to false
+    
+    if (_isDisableStyleCompression == null)
+      _isDisableStyleCompression = Boolean.FALSE;
+
+    return Boolean.TRUE.equals(_isDisableStyleCompression);
+
+  }
 
   // Implementation of StyleProvider which does nothing - used as a
   // placeholder when we can't get the real StyleProvider
@@ -198,7 +261,8 @@
   private String  _generatedFilesPath;
   private StyleProvider _styleProvider;
   private StyleMap _styleMap;
-
+  private Boolean  _isDisableStyleCompression;
+  
   private static final TrinidadLogger _LOG =
     TrinidadLogger.createTrinidadLogger(StyleContextImpl.class);
 }

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java?rev=731738&r1=731737&r2=731738&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/StyleSheetRenderer.java Mon Jan  5 13:57:59 2009
@@ -31,7 +31,6 @@
 import org.apache.myfaces.trinidad.bean.FacesBean;
 import org.apache.myfaces.trinidad.component.core.CoreStyleSheet;
 import org.apache.myfaces.trinidad.context.RenderingContext;
-import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderingContext;
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
 import org.apache.myfaces.trinidadinternal.style.StyleProvider;
@@ -78,7 +77,7 @@
   @Override
   protected void encodeAll(
     FacesContext        context,
-    RenderingContext arc,
+    RenderingContext    arc,
     UIComponent         comp,
     FacesBean           bean) throws IOException
   {
@@ -90,10 +89,8 @@
     {
       List<String> uris = provider.getStyleSheetURIs(sContext);
 
-      // If the requestMap has a skin-id, a skin's stylesheet's id and suppressStylesheet
-      // is true, and the skin information matches our current skin, then it is safe
-      // to not write out the css. This means that it will be written out by the external
-      // source, like the portal container.
+      // Check if we want to write out the css into the page or not. In portlet mode the 
+      // producer tries to share the consumer's stylesheet if it matches exactly.
       boolean suppressStylesheet = _isSuppressStylesheet(context, arc);
       if (!suppressStylesheet)
       {
@@ -164,27 +161,26 @@
     }
   }
 
-  // returns true if we want to suppress the stylesheet.
-  // It checks for suppressStylesheet flag on the request map and
-  // for the skin-id on the request map to exist identically on the server.
-  //
-  // This is usually called in a portal environment when we want to suppress the
-  // producer (portlet)'s stylesheet and use the consumer (portal container)'s
-  // instead for performance enhancements.
-  private boolean _isSuppressStylesheet(FacesContext context,  RenderingContext arc)
-  {
 
-    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+  // In the portlet environment, the consumer might like the producers to share its stylesheet
+  // for performance reasons. To indicate this the producer sends a 
+  // suppress stylesheet parameter on the request map.
+  // returns true if the stylesheet should be suppressed and not written out in the page.
+  private boolean _isSuppressStylesheet(FacesContext context, RenderingContext arc)
+  {
 
-    boolean suppressStylesheet = "true".equals(requestMap.get(_SUPPRESS_STYLESHEET_ID_PARAM));
-    if (suppressStylesheet)
-    {
-      // getRequestMapSkin --
-      // See if a skin-id is requested on the requestMap. If so, then see if the Skin
-      // with that id exists on the server, and if it does, and if it is an exact match
-      // (styleSheetDocumentIds match), then it returns the Skin. Otherwise, it returns null
-      Skin requestMapSkin = ((CoreRenderingContext) arc).getRequestMapSkin();
-      return (requestMapSkin != null) ? true : false;
+    String outputMode = arc.getOutputMode();
+    if (XhtmlConstants.OUTPUT_MODE_PORTLET.equals(outputMode))
+    {  
+      Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+      boolean suppressStylesheet = "true".equals(requestMap.get(_SUPPRESS_STYLESHEET_ID_PARAM));
+      if (suppressStylesheet)
+      {
+        // the portlet producer requests that we suppress the stylesheet if the producer's skin
+        // and the consumer's skin match exactly.
+        return ((CoreRenderingContext) arc).isRequestMapStyleSheetIdAndSkinEqual(
+                                              context, arc.getSkin());
+      }
     }
     return false;
   }

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java?rev=731738&r1=731737&r2=731738&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java Mon Jan  5 13:57:59 2009
@@ -21,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -50,7 +49,6 @@
 
 import org.apache.myfaces.trinidad.skin.SkinAddition;
 import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderingContext;
-import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SkinProperties;
 import org.apache.myfaces.trinidadinternal.share.config.Configuration;
 import org.apache.myfaces.trinidadinternal.skin.icon.ReferenceIcon;
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
@@ -312,18 +310,19 @@
      RenderingContext arc
      )
    {
-     ExternalContext external  = FacesContext.getCurrentInstance().getExternalContext();
-     if (!"true".equals(
-          external.getInitParameter(
-            Configuration.DISABLE_CONTENT_COMPRESSION)))
+     FacesContext context = FacesContext.getCurrentInstance();
+     if (!_isDisableContentCompressionParameterTrue(context))
      {
-       StyleContext sContext = ((CoreRenderingContext)arc).getStyleContext();
-       StyleProvider sProvider = sContext.getStyleProvider();
-       return sProvider.getShortStyleClasses(sContext);
+        StyleContext sContext = ((CoreRenderingContext)arc).getStyleContext();
+        StyleProvider sProvider = sContext.getStyleProvider();  
+        // make sure that we want to disable style compression - there could be other
+        // reasons that the styleContext knows about.
+        if (!(sContext.isDisableStyleCompression()))
+          return sProvider.getShortStyleClasses(sContext);
      }
      return null;
    }
-
+   
   /**
    * Returns the StyleSheetDocument object which defines all of the
    * styles for this Skin, including any styles that are
@@ -917,6 +916,15 @@
       }
     }
   }
+  
+  // returns true if the web.xml explicitly has DISABLE_CONTENT_COMPRESSION set to true.
+  // else return false.
+  private boolean _isDisableContentCompressionParameterTrue(FacesContext context)
+  {
+    ExternalContext external  = context.getExternalContext();
+
+    return "true".equals(external.getInitParameter(Configuration.DISABLE_CONTENT_COMPRESSION));
+  }
 
   // a TranslationSource fills in the keyValueMap differently depending upon
   // if it is a map or a ResourceBundle.

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java?rev=731738&r1=731737&r2=731738&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java Mon Jan  5 13:57:59 2009
@@ -21,7 +21,6 @@
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
 import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.LocaleContext;
-import org.apache.myfaces.trinidad.skin.Skin;
 
 /**
  * The StyleContext interface is used to provide information
@@ -52,4 +51,5 @@
   public StyleMap getStyleMap();
   public AccessibilityProfile getAccessibilityProfile();
   public boolean isPortletMode();
+  public boolean isDisableStyleCompression();
 }

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?rev=731738&r1=731737&r2=731738&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java Mon Jan  5 13:57:59 2009
@@ -43,8 +43,6 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import javax.faces.context.FacesContext;
-
 import org.apache.myfaces.trinidad.context.AccessibilityProfile;
 import org.apache.myfaces.trinidad.context.LocaleContext;
 import org.apache.myfaces.trinidad.context.RenderingContext;
@@ -52,10 +50,8 @@
 import org.apache.myfaces.trinidad.skin.Icon;
 import org.apache.myfaces.trinidad.skin.Skin;
 import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
-import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderKit;
 import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderingContext;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SkinSelectors;
-import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.StyleSheetRenderer;
 import org.apache.myfaces.trinidadinternal.share.io.CachingNameResolver;
 import org.apache.myfaces.trinidadinternal.share.io.DefaultNameResolver;
 import org.apache.myfaces.trinidadinternal.share.io.InputStreamProvider;
@@ -331,7 +327,7 @@
     }
 
 
-    boolean compressedStyles = _isCompressStyles(null);
+    boolean compressedStyles = _isCompressStyles(context);
     if (compressedStyles)
     {
       if (baseName != null || contextName != null)
@@ -777,8 +773,9 @@
     // First figure out whether or not we need to compress the style classes.
     // We don't compress the style classes if the content compression flag is disabled or
     // if the skin is a portlet skin.
-    Skin skin = RenderingContext.getCurrentInstance().getSkin();
-    boolean compressStyles = _isCompressStyles(skin);
+    RenderingContext arc = RenderingContext.getCurrentInstance();
+    Skin skin = arc.getSkin();
+    boolean compressStyles = _isCompressStyles(context);
 
     StyleWriterFactoryImpl writerFactory = new StyleWriterFactoryImpl(_targetPath,
       getTargetStyleSheetName(context, document));
@@ -835,21 +832,11 @@
    * We don't compress the style classes if the content compression flag is disabled or
    * if the skin is a portlet skin.
    */
-  private boolean _isCompressStyles(Skin skin)
+  private boolean _isCompressStyles(StyleContext sContext)
   {
-    if (skin == null)
-      skin = RenderingContext.getCurrentInstance().getSkin();
-
-
-    String disableContentCompression =
-      FacesContext.getCurrentInstance().getExternalContext().
-      getInitParameter(StyleSheetRenderer.DISABLE_CONTENT_COMPRESSION);
-    // we do not compress if it is a portlet skin
-    boolean isPortletSkin =
-    CoreRenderKit.OUTPUT_MODE_PORTLET.equals(skin.getRenderKitId());
+    // if we are not disabling style compression, then we are compressing the styles
+    return !(sContext.isDisableStyleCompression());
 
-    return (!"true".equals(disableContentCompression)) &&
-                                             !isPortletSkin;
   }
 
   private List<String> _getFileNames(List<File> files)

Modified: myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts?rev=731738&r1=731737&r2=731738&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts Mon Jan  5 13:57:59 2009
@@ -238,11 +238,14 @@
 <!-- NO_SKIN_FACTORY -->
 <resource key="NO_SKIN_FACTORY">There is no SkinFactory</resource>
 
-<!-- REQUESTMAP_SKIN_NOT_USED_BECAUSE_STYLESHEETDOCUMENT_ID_NOT_MATCH_LOCAL_SKIN -->
-<resource key="REQUESTMAP_SKIN_NOT_USED_BECAUSE_STYLESHEETDOCUMENT_ID_NOT_MATCH_LOCAL_SKIN">The skin {0} specified on the requestMap will not be used because the styleSheetDocument id on the requestMap does not match the local skin''s styleSheetDocument''s id. It could mean the jars are not identical. For example, one might have trinidad-skins.xml''s skin-additions in a jar file on the class path that the other does not have.</resource>
+<!-- STYLESHEETDOCUMENT_ID_NOT_MATCH_LOCAL_SKIN -->
+<resource key="STYLESHEETDOCUMENT_ID_NOT_MATCH_LOCAL_SKIN">
+The skin {0} specified on the requestMap will be used even though the consumer''s skin''s styleSheetDocumentId on the requestMap does not match the local skin''s styleSheetDocument''s id.  This will impact performance since the consumer and prodcuer stylesheets cannot be shared. The producer styleclasses will not be compressed to avoid conflicts. A reason the ids do not match may be the jars are not identical on the producer and the consumer. For example, one might have trinidad-skins.xml''s skin-additions in a jar file on the class path that the other does not have.</resource>
+
+<!-- STYLESHEETDOCUMENT_ID_NOT_IN_REQUESTMAP -->
+<resource key="STYLESHEETDOCUMENT_ID_NOT_IN_REQUESTMAP">
+The skin {0} specified on the requestMap will be used even though the consumer''s skin''s styleSheetDocumentId was not in the requestMap. This will impact performance since the stylesheets cannot be shared between the producer and the consumer.</resource>
 
-<!-- REQUESTMAP_SKIN_NOT_USED_BECAUSE_STYLESHEETDOCUMENT_ID_NOT_IN_REQUESTMAP -->
-<resource key="REQUESTMAP_SKIN_NOT_USED_BECAUSE_STYLESHEETDOCUMENT_ID_NOT_IN_REQUESTMAP">The skin {0} specified on the requestMap will not be used because its styleSheetDocument id was not in the requestMap and it is needed to compare with the local skin''s styleSheetDocument''s id to make sure the skins are the same.</resource>
 
 <!-- REQUESTMAP_SKIN_NOT_USED_BECAUSE_NOT_EXIST -->
 <resource key="REQUESTMAP_SKIN_NOT_USED_BECAUSE_NOT_EXIST">The skin {0} specified on the requestMap will not be used because it does not exist.</resource>