You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2006/02/17 21:59:30 UTC

svn commit: r378625 - /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java

Author: imario
Date: Fri Feb 17 12:59:29 2006
New Revision: 378625

URL: http://svn.apache.org/viewcvs?rev=378625&view=rev
Log:
enhanced ComponentUtils.findFirstMessagesComponent to traverse through facets too
added a minimalistic panelLayout to inputAjax.jsp to place all the components within a facets

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java?rev=378625&r1=378624&r2=378625&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java Fri Feb 17 12:59:29 2006
@@ -16,8 +16,7 @@
 
 package org.apache.myfaces.custom.util;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.Iterator;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.html.HtmlMessages;
@@ -30,24 +29,30 @@
  */
 public class ComponentUtils
 {
-    private static Log log = LogFactory.getLog(ComponentUtils.class);
-
-    public static UIComponent findFirstMessagesComponent(FacesContext context, UIComponent root)
+    public static UIComponent findFirstMessagesComponent(FacesContext context, UIComponent base)
     {
-        UIComponent component = null;
-
-        for(int i = 0; i < root.getChildCount() && component == null; i++)
+    	if (base == null)
+    	{
+    		return null;
+    	}
+    	
+        if (base instanceof HtmlMessages)
         {
-            UIComponent child = (UIComponent)root.getChildren().get(i);
-
-            if (child != null && child instanceof HtmlMessages)
-            {
-                return child;
-            }
-
-            component = findFirstMessagesComponent(context, child);
+            return base;
         }
 
-        return component;
+        Iterator iterChildren = base.getFacetsAndChildren();
+        while (iterChildren.hasNext())
+        {
+        	UIComponent child = (UIComponent) iterChildren.next();
+            
+        	UIComponent found = findFirstMessagesComponent(context, child);
+        	if (found != null)
+        	{
+        		return found;
+        	}
+        }
+        
+        return null;
     }
 }