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 2008/02/16 01:39:09 UTC

svn commit: r628220 - in /myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src: main/java/org/apache/myfaces/trinidad/render/ main/java/org/apache/myfaces/trinidad/util/ main/xrts/org/apache/myfaces/trinidad/resource/ test/java/org/apache/m...

Author: jwaldman
Date: Fri Feb 15 16:39:08 2008
New Revision: 628220

URL: http://svn.apache.org/viewvc?rev=628220&view=rev
Log:
added a new test, FindRelativeComponentTest to make sure it is backward compatibile and works.
rewrote getRelativeId in RenderUtils to be backward compatible, and to do that I have to 
find the component, and if it isn't found, I can find it the 'old' way.
Therefore I use ComponentUtils's findRelativeComponent method from getRelativeId.
This will also help keep these in sync.

Added:
    myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java
Modified:
    myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
    myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
    myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
    myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java

Modified: myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java?rev=628220&r1=628219&r2=628220&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java (original)
+++ myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java Fri Feb 15 16:39:08 2008
@@ -27,6 +27,8 @@
 import javax.faces.context.FacesContext;
 
 import org.apache.myfaces.trinidad.component.UIXForm;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidad.util.ComponentUtils;
 
 /**
  * Generic utilities for rendering.
@@ -125,7 +127,8 @@
    * 
    * </p>
    * <p>
-   * It does not assume that the target component can be located.
+   * It does not assume that the target component can be located, although it does
+   * check. If it can't be found, returns the correct relativeId anyway.
    * </p>
    * <p>
    * A relativeId starting with
@@ -136,10 +139,9 @@
    * is a naming container).
    * A relativeId starting with '::' pops out of the 'from' component's
    * naming container. A relativeId with ':::' pops up two naming containers, etc.
-   * ComponentUtils.findRelativeComponent finds the component, whereas
+   * ComponentUtils.findRelativeComponent finds and returns the component, whereas
    * this method returns a relativeId that can be used during renderering 
    * so the component can be found in javascript on the client.
-   * This code is faster because it doesn't have to find the component.
    * </p>
    * @param context
    * @param from the component to search relative to
@@ -159,21 +161,68 @@
     
     if ((relativeId == null) || (relativeId.length() == 0))
       return null;
-    
-    int idLength = relativeId.length();
+
     // Figure out how many colons
-    int colonCount = 0;
-    while (colonCount < idLength)
-    {
-      if (relativeId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR)
-        break;
-      colonCount++;
-    }
+    int colonCount = _getColonCount(relativeId);
 
     // colonCount == 0: fully relative
     // colonCount == 1: absolute 
     // colonCount > 1: for each extra colon after 1, pop out of
     // the naming container (to the view root, if naming containers run out)
+    
+    if (colonCount == 1)
+      return relativeId.substring(1);
+    
+    // 
+    // We need to make it backward compatible, and 
+    // the only way is to use the findRelativeComponent code.
+    // This way we'll have a hint that the syntax is 'old' if 
+    // it can't be found. Plus, findRelativeComponent code has 
+    // backward compatibilty built in.
+    UIComponent component = 
+      ComponentUtils.findRelativeComponent(from, relativeId);
+    if (component == null && from instanceof NamingContainer)
+    {
+      component = ComponentUtils.findRelativeComponent(from.getParent(), relativeId);
+      if (component != null)
+      {
+        // TODO Log warning
+        _LOG.warning("DEPRECATED_RELATIVE_ID_SYNTAX", 
+          new Object[] {relativeId, from});
+      }
+    }
+    
+    // the component wasn't found, but go ahead and return something smart
+    if (component == null)
+    {
+      // TODO LOG warning
+      _LOG.warning("RELATIVE_ID_NOT_FOUND", 
+        new Object[] {relativeId, from});
+      return _getRelativeId(context, from, relativeId, colonCount);
+    }
+    else
+    {
+      return component.getClientId(context);
+    }
+
+  }
+
+
+  // This does NOT use findComponent
+  // ComponentUtils.findRelativeComponent finds the component, whereas
+  // this method returns a relativeId that can be used during renderering 
+  // so the component can be found in javascript on the client.
+  // This code is faster because it doesn't have to find the component.
+  // It is used when the getRelativeId's findRelativeComponent cannot find 
+  // the component. This way we can return the relativeId anyway.
+  private static String _getRelativeId(
+    FacesContext context,
+    UIComponent  from,
+    String       relativeId,
+    int          colonCount)
+  {
+
+
     if (colonCount == 1)
       return relativeId.substring(1);
     else if (colonCount > 1)
@@ -188,7 +237,6 @@
     {
       from = _getParentNamingContainer(from);
     }
-    
     // pop out of the naming containers if there are multiple colons
     // from will be null if there are no more naming containers
     for (int j = 1; j < colonCount; j++)
@@ -205,8 +253,10 @@
               NamingContainer.SEPARATOR_CHAR + relativeId);
     }
 
+
   }
 
+
   // Given a component, get its naming container. If the component
   // is a naming container, it will get its naming container.
   // This is different than the one in ComponentUtils. This one
@@ -225,6 +275,21 @@
 
     return null;
   }
-
+  
+  // Figure out how many colons
+  private static int _getColonCount(String relativeId)
+  {
+    int idLength = relativeId.length();
+    int colonCount = 0;
+    while (colonCount < idLength)
+    {
+      if (relativeId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR)
+        break;
+      colonCount++;
+    }
+    return colonCount;
+  }
+  static private final TrinidadLogger _LOG =
+    TrinidadLogger.createTrinidadLogger(RenderUtils.class);
 
 }

Modified: myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java?rev=628220&r1=628219&r2=628220&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java (original)
+++ myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java Fri Feb 15 16:39:08 2008
@@ -321,6 +321,7 @@
     return t;
   }
 
+
   /**
    * Find a component relative to another.
    * <p>
@@ -411,7 +412,7 @@
 
    /**
     * Find a component relative to another.
-    * This method is the same as the 'old' public findRelativeComponentDeprecated.
+    * This method is the same as the 'old' public findRelativeComponent.
    * This method is around so that the
    * new findRelativeComponent method is backward compatibility.
     * <p>
@@ -464,7 +465,7 @@
     UIComponent found = from.findComponent(relativeId);
     if (found != null)
     {
-      _LOG.warning("DEPRECATED_TRIGGER_SYNTAX", 
+      _LOG.warning("DEPRECATED_RELATIVE_ID_SYNTAX", 
         new Object[] {originalRelativeId, originalFrom});
     }
     return found;

Modified: myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts?rev=628220&r1=628219&r2=628220&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts Fri Feb 15 16:39:08 2008
@@ -396,7 +396,10 @@
  <!-- RESOURCE_PATH_CONTAINS_DOTS -->
  <resource key="RESOURCE_PATH_DOTS">The resource path {0} contains "..". Browsers resolve out the "..", so this is a suspicious path.</resource>
 
-<!-- DEPRECATED_TRIGGER_SYNTAX -->
-<resource key="DEPRECATED_TRIGGER_SYNTAX">Could not find partial trigger {0} from {1} with the supported partialTriggers syntax. The partial trigger was found with the deprecated syntax. Please use the supported syntax.</resource>
+<!-- DEPRECATED_RELATIVE_ID_SYNTAX -->
+<resource key="DEPRECATED_RELATIVE_ID_SYNTAX">Could not find the component with relative id {0} from {1} with the supported syntax. The component was found with the deprecated syntax. Please use the supported syntax.</resource>
+
+<!-- RELATIVE_ID_NOT_FOUND -->
+<resource key="RELATIVE_ID_NOT_FOUND">Could not find the component with relative id {0} from {1}. This method will return the relative id anyway. Please double-check the syntax and make sure the component exists.</resource>
 
 </resources>

Modified: myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java?rev=628220&r1=628219&r2=628220&view=diff
==============================================================================
--- myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java (original)
+++ myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java Fri Feb 15 16:39:08 2008
@@ -23,10 +23,13 @@
 
 import javax.faces.context.FacesContext;
 
+import javax.faces.render.Renderer;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.myfaces.trinidad.component.core.nav.CoreCommandButton;
 import org.apache.myfaces.trinidad.render.RenderUtils;
 
 
@@ -60,18 +63,25 @@
       String clientId = getId() + "_Client";
       return clientId;
     }
+    
+    public String getContainerClientId(FacesContext p1) 
+    { 
+      return getId();
+    }
+    
+    protected Renderer getRenderer(FacesContext context)
+    {
+      return null;
+    }
   }
   
   static private class TestUIXPanel extends UIXPanel
   {
-    @Override
-    public String getClientId(FacesContext context)
-    {
-      // NOTE - client ids cannot be cached because the generated
-      // value has to be dynamically calculated in some cases (UIData)
 
-      String clientId = getId() + "_Client";
-      return clientId;
+    
+    protected Renderer getRenderer(FacesContext context)
+    {
+      return null;
     }
   }
 
@@ -80,108 +90,160 @@
   @SuppressWarnings("unchecked")
   public void testButtonAndNamingContainerSiblings()
   {
-      // set up a button and a table that are siblings
-      // under a rootPanel (not a naming container)
-      // no naming containers above these components.
-      UIXCommand button1 = new UIXCommand();
+      // rootPanel
+      //     button1
+      //     table1
+      TestUIXPanel button1 = new TestUIXPanel();
       button1.setId("commandButton1");
-
       TestNamingContainer table1 = new TestNamingContainer();
       table1.setId("table1");
       TestUIXPanel rootPanel = new TestUIXPanel();
       rootPanel.setId("rootPanel");
       rootPanel.getChildren().add(button1);
       rootPanel.getChildren().add(table1);
+      TestUIXPanel tableChild = new TestUIXPanel();
+      tableChild.setId("tableChildId");
+      table1.getChildren().add(tableChild);
     
     String relativeId = 
       RenderUtils.getRelativeId(null, button1, "table1");
-    assertEquals("table1", relativeId);
+    assertEquals("table1_Client", relativeId);
     
-    // to get to the commandButton from the table, you need to pop out of the 
-    // table.
     relativeId = 
-      RenderUtils.getRelativeId(null, table1, "::commandButton1");
-    assertEquals("commandButton1", relativeId);
-    // old way starts at table1's parent, so it would go too far out.
-    //assertEquals("::commandButton1", relativeId);
-
-    // this is how you get to something INSIDE the table
+      RenderUtils.getRelativeId(null, button1, ":table1");
+    assertEquals("table1", relativeId);
+    
+    // new way would find nothing, so we'd have to get something logical
     relativeId = 
       RenderUtils.getRelativeId(null, table1, "someRandomId");
-    assertEquals("table1_Client:someRandomId", relativeId);    
-    // old way this would get the peer
-    //assertEquals("someRandomId", relativeId);
+    assertEquals("table1_Client:someRandomId", relativeId);
     
     relativeId = 
       RenderUtils.getRelativeId(null, table1, ":commandButton1");
-    assertEquals("commandButton1", relativeId); 
+    assertEquals("commandButton1", relativeId);
+
+    // to get to the commandButton from the table, you need to pop out of the 
+    // table  
+    relativeId = 
+      RenderUtils.getRelativeId(null, table1, "::commandButton1");
+    assertEquals("commandButton1", relativeId);
     
+    // backward compatibility test -- this was the old syntax for siblings to the table.
+    // this should be found by looking at the nc's parent from findRelativeComponent
     relativeId = 
-      RenderUtils.getRelativeId(null, button1, ":table1");
-    assertEquals("table1", relativeId);
-
+      RenderUtils.getRelativeId(null, table1, "commandButton1");
+    assertEquals("commandButton1", relativeId);
+       
+    // backward compatibility test -- this was the old syntax for children to the table.
+    relativeId = 
+      RenderUtils.getRelativeId(null, table1, "table1:tableChildId");
+    assertEquals("table1:tableChildId", relativeId); 
+     // this is the new syntax for children to the table
+    relativeId = 
+      RenderUtils.getRelativeId(null, table1, "tableChildId");
+    assertEquals("table1:tableChildId", relativeId); 
 
   }
 
 
 
+
   @SuppressWarnings("unchecked")
   public void testRelativeSearch()
   {
-    /*<f:subview id="ncRoot">
-     *  <commandButton1>
-     *  <commandButton2>
-     *   <f:subview id="nc1">
-     *     <tr:inputText id="inputA" pT="::commandButton1"/>
-           <tr:panelGroupLayout>
-             <tr:inputText
-             id="input1"
-             for="::commandButton1"/>
-           </tr:panelGroupLayout>
-          </f:subview>
-       </f:subview>
-     */
+
 
       // set up component hierarchy
       UIXForm form = new UIXForm(); form.setId("formId");
       TestNamingContainer ncRoot = new TestNamingContainer(); ncRoot.setId("ncRoot");
-      UIXCommand button1 = new UIXCommand();
+      TestUIXPanel button1 = new TestUIXPanel();
       button1.setId("button1");
-      UIXCommand button2 = new UIXCommand();
+      TestUIXPanel button2 = new TestUIXPanel();
       button2.setId("button2");
+      TestUIXPanel rootButton = new TestUIXPanel();
+      rootButton.setId("rootButton");
 
       form.getChildren().add(ncRoot);
+      form.getChildren().add(rootButton);
       ncRoot.getChildren().add(button1);
       ncRoot.getChildren().add(button2);
 
-      TestNamingContainer nc = new TestNamingContainer(); 
-      nc.setId("nc1");
+      TestNamingContainer nc1 = new TestNamingContainer(); 
+      nc1.setId("nc1");
 
           
       UIXInput inputA = new UIXInput(); inputA.setId("inputA");
       UIXPanel panel1 = new UIXPanel(); panel1.setId("panel1");
       UIXInput input1 = new UIXInput(); input1.setId("input1");
-      ncRoot.getChildren().add(nc);
-      nc.getChildren().add(inputA);
-      nc.getChildren().add(panel1);
+      ncRoot.getChildren().add(nc1);
+      nc1.getChildren().add(inputA);
+      nc1.getChildren().add(panel1);
       panel1.getChildren().add(input1);
       
-    
+    /*<f:subview id="ncRoot">
+     *  <commandButton1>
+     *  <commandButton2>
+     *   <f:subview id="nc1">
+     *     <tr:inputText id="inputA" pT="::commandButton1"/>
+           <tr:panelGroupLayout>
+             <tr:inputText
+             id="input1"
+             for="::commandButton1"/>
+           </tr:panelGroupLayout>
+          </f:subview>
+       </f:subview>
+       rootButton
+     */ 
+      
     String relativeId = 
       RenderUtils.getRelativeId(null, input1, "::button1");
-    // new way should pop OUT of this with two ::
-    assertEquals("ncRoot_Client:button1", relativeId); 
-    // old way
-    //assertEquals("nc1_Client:button1", relativeId);
+    // new way should pop OUT of ONE naming container and will find it
+    assertEquals("ncRoot:button1", relativeId); 
 
     
- 
     relativeId = 
       RenderUtils.getRelativeId(null, input1, ":::button1");
-    // new way should pop OUT of both NC with two :::
-    assertEquals("button1", relativeId); 
-    // old way
-    //assertEquals("ncRoot_Client:button1", relativeId);
+    // new way should pop OUT of TWO naming containers and will find not find it
+    // since it is in ncRoot and the base is now the view root.
+    // so it goes to the old findRelativeComponent, and this will find it.
+    assertEquals("ncRoot:button1", relativeId); 
+
+
+    relativeId = 
+      RenderUtils.getRelativeId(null, input1, "randomPeer");
+    // randomPeer doesn't exist, so new way won't find it. 
+    // uses code that doesn't need to find the component to return this:
+    assertEquals("nc1_Client:randomPeer", relativeId);  
+    
+    relativeId = 
+      RenderUtils.getRelativeId(null, input1, "::randomPeer");
+    // randomPeer doesn't exist, so new way won't find it. 
+    // uses code that doesn't need to find the component to return this:
+    assertEquals("ncRoot_Client:randomPeer", relativeId); 
+ 
+    // rootButton is child of form and sibling to ncRoot. It's 2 nc up from input1
+    relativeId = 
+      RenderUtils.getRelativeId(null, input1, ":::rootButton");
+    // new way should pop OUT of both NC with ::: and will find it
+    assertEquals("rootButton", relativeId); 
+
+ 
+    // rootButton is child of form and sibling to ncRoot. It's 2 nc up from input1
+    relativeId = 
+      RenderUtils.getRelativeId(null, input1, "::rootButton");
+    // new way should pop OUT of one NC with ::, so it can't find it
+    // the 'old' findRelativeComponent can't find it either.
+    // so it returns what the old getRelativeId would have returned
+    // old way goes up to the current naming container nc1
+    // old 'new' way will return nc1_Root:rootButton
+    assertEquals("ncRoot_Client:rootButton", relativeId);
+
+    
+    // rootButton is child of form and sibling to ncRoot. It's 2 nc up from input1
+    relativeId = 
+      RenderUtils.getRelativeId(null, input1, "::::rootButton");
+    // new way should pop OUT of ALL NCs and will find it.
+    assertEquals("rootButton", relativeId);
     
 
     
@@ -189,18 +251,9 @@
       RenderUtils.getRelativeId(null, input1, "::::button1");
     // new way should return this
     assertEquals("button1", relativeId);    
-    // old way returns the original id (THIS IS A BUG).
-    //assertEquals(":::::button1", relativeId);
-    
-
     
     relativeId = 
       RenderUtils.getRelativeId(null, input1, ":::::button1");
-    
-    // old way returns the original id (THIS IS A BUG).
-    //assertEquals(":::::button1", relativeId);
-    
-    // new way should return this
     assertEquals("button1", relativeId);
   }
 

Added: myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java?rev=628220&view=auto
==============================================================================
--- myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java (added)
+++ myfaces/trinidad/branches/jwaldman_1.2-issue936/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java Fri Feb 15 16:39:08 2008
@@ -0,0 +1,213 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.myfaces.trinidad.util;
+
+import junit.framework.TestCase;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.myfaces.trinidad.component.UIXCommand;
+import org.apache.myfaces.trinidad.component.UIXInput;
+import org.apache.myfaces.trinidad.component.UIXPanel;
+import org.apache.myfaces.trinidad.component.UIXTable;
+
+public class FindRelativeComponentTest extends TestCase
+{
+  public static final Test suite()
+  {
+    return new TestSuite(FindRelativeComponentTest.class);
+  }
+  
+  public static void main(String[] args) throws Throwable
+  {
+    junit.textui.TestRunner.run(suite());
+  }
+
+  public FindRelativeComponentTest(
+    String testName)
+  {
+    super(testName);
+  }
+
+  static private class TestNamingContainer extends UIXPanel
+                                           implements NamingContainer
+  {
+
+  }
+
+  
+  // Test sibling components
+  @SuppressWarnings("unchecked")
+  public void testSiblingButtons()
+  {
+
+      UIXCommand button1 = new UIXCommand();
+      button1.setId("commandButton1");
+      UIXCommand button2 = new UIXCommand();
+      button2.setId("commandButton2");
+      UIXPanel rootPanel = new UIXPanel();
+      rootPanel.getChildren().add(button1);
+      rootPanel.getChildren().add(button2);
+      
+      UIComponent cmp = 
+          ComponentUtils.findRelativeComponent(button2, "commandButton1");
+      // old and new are the same
+      assertEquals(cmp, button1);
+      
+      cmp = ComponentUtils.findRelativeComponent(button2, "::::::commandButton1");
+      // old and new are the same
+      assertEquals(cmp, button1);
+
+    
+  }
+    
+  // Test sibling components where one is a table and one is a button
+  @SuppressWarnings("unchecked")
+  public void testSiblingWithTable()
+  {
+      // panel
+      //    table1
+      //       tableChild
+      //    button1 (table1 & button1 peers)
+      UIXCommand button1 = new UIXCommand();
+      button1.setId("commandButton1");
+  
+      UIXTable table1 = new UIXTable();
+      table1.setId("table1");
+      UIXPanel rootPanel = new UIXPanel();
+      rootPanel.getChildren().add(button1);
+      rootPanel.getChildren().add(table1);
+      UIXPanel tableChild = new UIXPanel();
+      tableChild.setId("tableChildId");
+      table1.getChildren().add(tableChild);
+      
+      
+      UIComponent cmp =
+        ComponentUtils.findRelativeComponent(table1,"::commandButton1");
+       // new & old (because  in old it starts from the viewRoot)
+      assertEquals(button1, cmp);
+      
+      cmp = ComponentUtils.findRelativeComponent(table1, "commandButton1");
+      // old & new are the same
+      // uses findComponent rules if it doesn't start with multiple colons
+      // - if this UIComponent is a NamingContainer it will serve as the basis.
+      assertEquals(null, cmp);
+      
+    cmp = ComponentUtils.findRelativeComponent(button1, "table1");
+    assertEquals(table1, cmp);
+    
+    cmp = ComponentUtils.findRelativeComponent(button1, "tableChildId");
+    assertEquals(null, cmp);
+    
+    cmp = ComponentUtils.findRelativeComponent(button1, "table1:tableChildId");
+    assertEquals(tableChild, cmp);
+    
+    cmp = ComponentUtils.findRelativeComponent(table1, "tableChildId");
+    assertEquals(tableChild, cmp);
+    
+    cmp = ComponentUtils.findRelativeComponent(tableChild, "table1");
+    assertEquals(table1, cmp);
+    
+    cmp = ComponentUtils.findRelativeComponent(tableChild, ":commandButton1");
+    assertEquals(button1, cmp);
+    
+    cmp = ComponentUtils.findRelativeComponent(tableChild, ":::commandButton1");
+    assertEquals(button1, cmp);
+    
+    cmp = ComponentUtils.findRelativeComponent(tableChild, "::commandButton1");   
+    assertEquals(button1, cmp); // new way
+    //assertEquals(null, cmp); // old way
+    
+
+  }
+    
+
+
+  @SuppressWarnings("unchecked")
+  public void testRelativeSearch()
+  {
+    /*<f:subview id="ncRoot">
+     *  <commandButton1>
+     *  <commandButton2>
+     *     <f:subview id="nc1">
+     *     <tr:inputText id="inputA" pT="::commandButton1"/>
+           <tr:panelGroupLayout>
+             <tr:inputText 
+             id="input1"
+             partialTriggers="::commandButton1"/>
+           </tr:panelGroupLayout>
+          </f:subview>
+       </f:subview>
+     */
+
+    // set up component hierarchy
+    UIForm form = new UIForm();
+    TestNamingContainer ncRoot = new TestNamingContainer(); ncRoot.setId("ncRoot");
+    UIXCommand button1 = new UIXCommand();
+    button1.setId("commandButton1");
+    UIXCommand button2 = new UIXCommand();
+    button2.setId("commandButton2");
+    
+    form.getChildren().add(ncRoot);
+    ncRoot.getChildren().add(button1);
+    ncRoot.getChildren().add(button2);
+      
+    TestNamingContainer nc = new TestNamingContainer(); nc.setId("nc1");
+    UIXInput inputA = new UIXInput(); inputA.setId("inputA");
+    UIXPanel panel = new UIXPanel(); panel.setId("panel1");
+    UIXInput input1 = new UIXInput(); input1.setId("input1");  
+    ncRoot.getChildren().add(nc);
+    nc.getChildren().add(inputA);
+    nc.getChildren().add(panel);
+    panel.getChildren().add(input1);
+      
+    // input1's parent is panel. panel's parent is nc1 (::) goes there. ::: goes to ncRoot
+    // in old way. New way pops OUT of nc1 with '::'.
+    UIComponent cmp =
+      ComponentUtils.findRelativeComponent(input1,":::commandButton1");
+    assertEquals(button1, cmp); // old way
+    // assertEquals(null, cmp); // new way (popped too far), so the code looks the old way
+    
+    cmp = ComponentUtils.findRelativeComponent(input1, "::::ncRoot:commandButton1");
+    assertEquals(button1, cmp); // old way & new way
+    
+    cmp = ComponentUtils.findRelativeComponent(input1, ":::ncRoot:commandButton1");
+    assertEquals(button1, cmp); // old way
+    
+    
+    // inputA's parent is nc1. ::  will get you there. : will pop you out. /old way
+    // :: will pop you out of nc1
+    cmp = ComponentUtils.findRelativeComponent(inputA, ":::commandButton1");
+    assertEquals(button1, cmp); // old way
+    //assertEquals(null, cmp);   // new way
+    
+    cmp = ComponentUtils.findRelativeComponent(inputA, "::ncRoot:commandButton1");
+    //assertEquals(null, cmp); // old way
+    assertEquals(button1, cmp);   // new way    
+ 
+  }
+
+
+}
+