You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/08/14 11:58:50 UTC

svn commit: r804148 - in /myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago: component/AbstractUIPage.java component/AbstractUIPanel.java component/AbstractUITabGroup.java util/LayoutUtils.java

Author: lofwyr
Date: Fri Aug 14 09:58:49 2009
New Revision: 804148

URL: http://svn.apache.org/viewvc?rev=804148&view=rev
Log:
TOBAGO-606: Layout-Manager
 - support f:subview: ignore the UIComponent and use the children for layouting

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtils.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java?rev=804148&r1=804147&r2=804148&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPage.java Fri Aug 14 09:58:49 2009
@@ -33,6 +33,7 @@
 import org.apache.myfaces.tobago.model.PageStateImpl;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 import org.apache.myfaces.tobago.util.DebugUtils;
+import org.apache.myfaces.tobago.util.LayoutUtils;
 import org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataRequest;
 
 import javax.faces.FacesException;
@@ -333,13 +334,7 @@
 
 // LAYOUT Begin
   public List<LayoutComponent> getComponents() {
-    List<LayoutComponent> result = new ArrayList<LayoutComponent>();
-    for (UIComponent uiComponent : (List<UIComponent>) getChildren()) {
-     if (uiComponent instanceof LayoutComponent) {
-       result.add((LayoutComponent) uiComponent);
-     }
-    }
-    return result;
+    return LayoutUtils.findLayoutChildren(this);
   }
 
   public LayoutManager getLayoutManager() {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java?rev=804148&r1=804147&r2=804148&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUIPanel.java Fri Aug 14 09:58:49 2009
@@ -23,11 +23,10 @@
 import org.apache.myfaces.tobago.layout.LayoutComponent;
 import org.apache.myfaces.tobago.layout.LayoutContainer;
 import org.apache.myfaces.tobago.layout.LayoutManager;
+import org.apache.myfaces.tobago.util.LayoutUtils;
 
-import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
 public abstract class AbstractUIPanel extends UIPanelBase implements LayoutContainer, LayoutComponent {
@@ -76,13 +75,7 @@
   }
 
   public List<LayoutComponent> getComponents() {
-    List<LayoutComponent> result = new ArrayList<LayoutComponent>();
-    for (UIComponent uiComponent : (List<UIComponent>) getChildren()) {
-      if (uiComponent instanceof LayoutComponent) {
-        result.add((LayoutComponent) uiComponent);
-      }
-    }
-    return result;
+    return LayoutUtils.findLayoutChildren(this);
   }
 
   public LayoutManager getLayoutManager() {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java?rev=804148&r1=804147&r2=804148&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITabGroup.java Fri Aug 14 09:58:49 2009
@@ -29,6 +29,7 @@
 import org.apache.myfaces.tobago.layout.LayoutComponent;
 import org.apache.myfaces.tobago.layout.LayoutContainer;
 import org.apache.myfaces.tobago.layout.LayoutManager;
+import org.apache.myfaces.tobago.util.LayoutUtils;
 
 import javax.faces.component.ActionSource;
 import javax.faces.component.UIComponent;
@@ -314,13 +315,7 @@
 
   // LAYOUT Begin
   public List<LayoutComponent> getComponents() {
-    List<LayoutComponent> result = new ArrayList<LayoutComponent>();
-    for (UIComponent uiComponent : (List<UIComponent>) getChildren()) {
-      if (uiComponent instanceof LayoutComponent) {
-        result.add((LayoutComponent) uiComponent);
-      }
-    }
-    return result;
+    return LayoutUtils.findLayoutChildren(this);
   }
 
   public LayoutManager getLayoutManager() {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtils.java?rev=804148&r1=804147&r2=804148&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtils.java Fri Aug 14 09:58:49 2009
@@ -22,9 +22,12 @@
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.Form;
+import org.apache.myfaces.tobago.layout.LayoutComponent;
+import org.apache.myfaces.tobago.layout.LayoutContainer;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.UINamingContainer;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 import java.util.regex.Pattern;
@@ -101,5 +104,20 @@
     }
     return true;
   }
-}
 
+  public static List<LayoutComponent> findLayoutChildren(LayoutContainer container) {
+    List<LayoutComponent> result = new ArrayList<LayoutComponent>();
+    addLayoutChildren((UIComponent) container, result);
+    return result;
+  }
+
+  private static void addLayoutChildren(UIComponent component, List<LayoutComponent> result) {
+    for (UIComponent child : (List<UIComponent>) component.getChildren()) {
+      if (child instanceof LayoutComponent) {
+        result.add((LayoutComponent) child);
+      } else {
+        addLayoutChildren(child, result);
+      }
+    }
+  }
+}