You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2010/11/17 00:22:02 UTC

svn commit: r1035857 - /myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java

Author: arobinson74
Date: Tue Nov 16 23:22:02 2010
New Revision: 1035857

URL: http://svn.apache.org/viewvc?rev=1035857&view=rev
Log:
TRINIDAD-1961 - Change the flatten code to avoid flattening composite components

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=1035857&r1=1035856&r2=1035857&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java Tue Nov 16 23:22:02 2010
@@ -172,13 +172,7 @@ abstract public class UIXComponent exten
 
         try
         {
-          // Optimize the cases of UINamingContainer (<f:subview>) and UIPanel -
-          // we will treat these components as FlattenedComponents because they do not render
-          // any DOM
-          // Note that JSF 2.0 creates UIPanel wrappers around multiple components
-          // inside of <f:facet>
-          if (UINamingContainer.class == child.getClass() ||
-              UIPanel.class == child.getClass())
+          if (isFlattenableCoreComponent(child))
           {
             processed =
                 processFlattenedChildren(context, cpContext, childProcessor,
@@ -1087,6 +1081,33 @@ abstract public class UIXComponent exten
     throw new UnsupportedOperationException();
   }
 
+  /**
+   * Determine if we can flatten a core JSF component.
+   * @param component The component
+   * @return true if the component is a core JSF component and we can
+   * flatten it successfully.
+   */
+  private static boolean isFlattenableCoreComponent(UIComponent component)
+  {
+    // Optimize the cases of UINamingContainer (<f:subview>) and UIPanel -
+    // we will treat these components as FlattenedComponents because they do not render
+    // any DOM.
+    // Also note that as of JSF 2.0, UINamingContainer components are built
+    // by f:subview, as well as composite components.
+    Class<? extends UIComponent> componentClass = component.getClass();
+
+    if (UINamingContainer.class == componentClass)
+    {
+      // Check to see if this component was created as a composite
+      // component, which we cannot flatten
+      return component.getFacet(UIComponent.COMPOSITE_FACET_NAME) == null;
+    }
+
+    // Note that JSF 2.0 creates UIPanel wrappers around multiple components
+    // inside of <f:facet>
+    return UIPanel.class == componentClass;
+  }
+
   private static final TrinidadLogger _LOG =
     TrinidadLogger.createTrinidadLogger(UIXComponent.class);
 }