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 2013/09/15 18:59:12 UTC

svn commit: r1523460 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets: compiler/UIInstructionHandler.java tag/jsf/ComponentSupport.java tag/jsf/ComponentTagHandlerDelegate.java

Author: lu4242
Date: Sun Sep 15 16:59:12 2013
New Revision: 1523460

URL: http://svn.apache.org/r1523460
Log:
MYFACES-3774 [perf] use facetName as a hint when try to find a component on refresh view algorithm 

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java?rev=1523460&r1=1523459&r2=1523460&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UIInstructionHandler.java Sun Sep 15 16:59:12 2013
@@ -92,7 +92,14 @@ final class UIInstructionHandler extends
             
             if (mctx.isRefreshingSection())
             {
-                c = ComponentSupport.findChildByTagId(parent, id);
+                if (facetName != null)
+                {
+                    c = ComponentSupport.findChildInFacetByTagId(parent, id, facetName);
+                }
+                else
+                {
+                    c = ComponentSupport.findChildInChildrenByTagId(parent, id);
+                }
             }
             boolean componentFound = false;
             if (c != null)

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java?rev=1523460&r1=1523459&r2=1523460&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentSupport.java Sun Sep 15 16:59:12 2013
@@ -137,10 +137,73 @@ public final class ComponentSupport
                 }
             }
         }
-
         return null;
     }
 
+    public static UIComponent findChildInFacetByTagId(
+        UIComponent parent, String id, String facetName)
+    {
+        if (parent.getFacetCount() > 0)
+        {
+            UIComponent facet = parent.getFacet(facetName);
+            if (facet != null)
+            {
+                // check if this is a dynamically generated UIPanel
+                if (Boolean.TRUE.equals(facet.getAttributes()
+                             .get(FACET_CREATED_UIPANEL_MARKER)))
+                {
+                    // only check the children and facets of the panel
+                    if (facet.getChildCount() > 0)
+                    {
+                        for (int i = 0, childCount = facet.getChildCount(); i < childCount; i ++)
+                        {
+                            UIComponent child = facet.getChildren().get(i);
+                            if (id.equals(child.getAttributes().get(MARK_CREATED)))
+                            {
+                                return child;
+                            }
+                        }
+                    }
+                    if (facet.getFacetCount() > 0)
+                    {
+                        Iterator<UIComponent> itr2 = facet.getFacets().values().iterator();
+                        while (itr2.hasNext())
+                        {
+                            UIComponent child = itr2.next();
+                            if (id.equals(child.getAttributes().get(MARK_CREATED)))
+                            {
+                                return child;
+                            }
+                        }
+                    }
+                }
+                else if (id.equals(facet.getAttributes().get(MARK_CREATED)))
+                {
+                    return facet;
+                }
+            }
+            return facet;
+        }
+        return null;
+    }
+    
+    public static UIComponent findChildInChildrenByTagId(
+        UIComponent parent, String id)
+    {
+        if (parent.getChildCount() > 0)
+        {
+            for (int i = 0, childCount = parent.getChildCount(); i < childCount; i ++)
+            {
+                UIComponent child = parent.getChildren().get(i);
+                if (id.equals(child.getAttributes().get(MARK_CREATED)))
+                {
+                    return child;
+                }
+            }
+        }
+        return null;
+    }
+    
     /**
      * By TagId, find Child
      * 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java?rev=1523460&r1=1523459&r2=1523460&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java Sun Sep 15 16:59:12 2013
@@ -211,7 +211,14 @@ public class ComponentTagHandlerDelegate
             }
             else
             {
-                c = ComponentSupport.findChildByTagId(parent, id); 
+                if (facetName != null)
+                {
+                    c = ComponentSupport.findChildInFacetByTagId(parent, id, facetName);
+                }
+                else
+                {
+                    c = ComponentSupport.findChildInChildrenByTagId(parent, id);
+                }
             }
         }
         boolean componentFound = false;