myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arobinso...@apache.org
Subject svn commit: r835112 - in /myfaces/trinidad/branches/ar_Issue1633: trinidad-api/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/ trinidad-api/src/main/java/org/apache/myfac...
Date Wed, 11 Nov 2009 22:50:04 GMT
Author: arobinson74
Date: Wed Nov 11 22:50:04 2009
New Revision: 835112

URL: http://svn.apache.org/viewvc?rev=835112&view=rev
Log:
Remove the deprecated support, update the tests, use findRelativeComponent instead of findComponent
to avoid slowing down findComponent, and have RenderUtils.getRelativeId use findRelativeComponent
to avoid bugs with relocated components

Modified:
    myfaces/trinidad/branches/ar_Issue1633/trinidad-api/pom.xml
    myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
    myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
    myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
    myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java
    myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java
    myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/pom.xml
    myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-api/pom.xml?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-api/pom.xml (original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-api/pom.xml Wed Nov 11 22:50:04 2009
@@ -94,6 +94,12 @@
       <plugin>
         <groupId>org.apache.myfaces.trinidadbuild</groupId>
         <artifactId>maven-jdev-plugin</artifactId>
+        <configuration>
+          <projectHasTests>true</projectHasTests>
+          <testSourceRoots>
+            <file>${project.basedir}/src/test</file>
+          </testSourceRoots>
+        </configuration>
       </plugin>
 
       <plugin>

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
(original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
Wed Nov 11 22:50:04 2009
@@ -481,21 +481,19 @@
   }
 
   /**
-   * @inheritDoc
-   * <p>In addition to the standard {@link UIComponent#findComponent(String)} functionality,
-   * <c>UIXComponent</c> supports relative ID support in the find component method.
This involves
-   * the resolution of Trinidad scoped IDs (IDs that search in parent naming containers using
-   * multiple colons). See the static {@link #findComponent(UIComponent, String)} method
for
-   * more information on this syntax.</p>
+   * Find a component relative to another.
    *
-   * @param expr The expression to use to find the component
-   * @return The component if found, otherwise null
+   * @param scopedId the relative id path from the 'from' component to the
+   *                 component to find
+   * @return the component if found, null otherwise
+   * @see org.apache.myfaces.trinidad.render.RenderUtils#getRelativeId
+   * @see javax.faces.component.UIComponent#findComponent
+   * @see #findRelativeComponent(Component, String)
    */
-  @Override
-  public UIComponent findComponent(
-    String expr)
+  public UIComponent findRelativeComponent(
+    String scopedId)
   {
-    return _findComponentImpl(this, expr);
+    return _findRelativeComponentImpl(this, scopedId);
   }
 
   /**
@@ -515,20 +513,13 @@
    * @see org.apache.myfaces.trinidad.render.RenderUtils#getRelativeId
    * @see javax.faces.component.UIComponent#findComponent
    */
-  public static UIComponent findComponent(
+  public static UIComponent findRelativeComponent(
     UIComponent from,
     String      scopedId)
   {
-    if (from == null)
-      return null;
-
-    if (from instanceof UIXComponent)
-    {
-      // UIXComponent can handle relative IDs in its findComponent method
-      return from.findComponent(scopedId);
-    }
-
-    return _findComponentImpl(from, scopedId);
+    return (from instanceof UIXComponent) ?
+      ((UIXComponent)from).findRelativeComponent(scopedId) :
+      _findRelativeComponentImpl(from, scopedId);
   }
 
   /**
@@ -635,6 +626,7 @@
     return true;
   }
 
+
   /**
    * <p>
    * Called when visiting the component during optimized partial page encoding so that the
@@ -844,42 +836,47 @@
    */
   abstract public String getContainerClientId(FacesContext context, UIComponent child);
 
-  private static UIComponent _findComponentImpl(
+  private static UIComponent _findRelativeComponentImpl(
     UIComponent from,
-    String scopedId)
+    String      scopedId)
   {
-    boolean isRelative = scopedId.startsWith("::", 0);
+    if (from == null) { return null; }
 
-    if (isRelative)
+    // Is this actually a relative ID syntax? If not, use the standard find
+    // component method
+    if (!scopedId.startsWith("::"))
     {
-      // if the component is not a NamingContainer, then we need to
-      // get the component's naming container and set this as the 'from'.
-      // this way we'll pop out of the component's
-      // naming container if there is are multiple colons.
-      if (!(from instanceof NamingContainer))
-      {
-        from = _getParentNamingContainerOrViewRoot(from);
-
-        if (from instanceof UIXComponent)
-        {
-          // The parent naming container is a UIXComponent, let it process the resolution
-          // of the find in case it has overridden the default behavior
-          return ((UIXComponent)from).findComponent(scopedId);
-        }
-      }
+      return from.findComponent(scopedId);
+    }
 
-      // Pop out of the current naming container and get the parent naming container
+    // if the component is not a NamingContainer, then we need to
+    // get the component's naming container and set this as the 'from'.
+    // this way we'll pop out of the component's
+    // naming container if there is are multiple colons.
+    if (!(from instanceof NamingContainer))
+    {
+      UIComponent origFrom = from;
       from = _getParentNamingContainerOrViewRoot(from);
 
-      // Strip off both colons if there are only 2 at the start, otherwise strip off one
-      scopedId = (scopedId.length() >= 3 && scopedId.charAt(2) == ':')
-        ? scopedId.substring(1) : scopedId.substring(2);
-
-      // Let the naming container resolve the remainder
-      return UIXComponent.findComponent(from, scopedId);
+      if (from instanceof UIXComponent && from != origFrom)
+      {
+        // The parent naming container is a UIXComponent, let it process the
+        // resolution of the find in case it has overridden the default behavior
+        // (Call the component directly instead of the static method to avoid
+        // one more method call on the stack)
+        return ((UIXComponent)from).findRelativeComponent(scopedId);
+      }
     }
 
-    return from.findComponent(scopedId);
+    // Pop out of the current naming container and get the parent naming container
+    from = _getParentNamingContainerOrViewRoot(from);
+
+    // Strip off both colons if there are only 2 at the start, otherwise strip off one
+    scopedId = (scopedId.length() >= 3 && scopedId.charAt(2) == ':') ?
+      scopedId.substring(1) : scopedId.substring(2);
+
+    // Let the naming container resolve the remainder
+    return UIXComponent.findRelativeComponent(from, scopedId);
   }
 
   /**
@@ -898,4 +895,4 @@
     }
     return from;
   }
-}
+}
\ No newline at end of file

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
(original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/RenderUtils.java
Wed Nov 11 22:50:04 2009
@@ -6,9 +6,9 @@
  *  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
@@ -19,6 +19,7 @@
 package org.apache.myfaces.trinidad.render;
 
 import java.io.IOException;
+
 import java.util.List;
 
 import javax.faces.component.NamingContainer;
@@ -26,9 +27,9 @@
 import javax.faces.component.UIForm;
 import javax.faces.context.FacesContext;
 
+import org.apache.myfaces.trinidad.component.UIXComponent;
 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.
@@ -104,29 +105,29 @@
   }
 
   /**
-   * Given a 'from' component and a relativeId, 
+   * Given a 'from' component and a relativeId,
    * return the clientId for use at rendering time that will identify the
    * id of the component you are referencing on the client.
    * This is used for attributes like e.g. "for" and "chooseId".
-   * 
+   *
    * <p>
    * e.g., given this hierarchy
    * <br/>
-   *  &lt;f:subview id="aaa"&gt;  
+   *  &lt;f:subview id="aaa"&gt;
    *    &lt;f:subview id="xxx"&gt;<br/>
-           &lt;tr:chooseColor id="cp1" .../&gt;<br/>
-            &lt;f:subview id="yyy"><br/>
-               &lt;tr:inputColor id="sic1" chooseId="::cp1" .../&gt;<br/>
-            &lt;/f:subview&gt;<br/>
-         &lt;/f:subview&gt;   
-      &lt;/f:subview&gt;<br/>
-    </p>
-    <p>
+   *        &lt;tr:chooseColor id="cp1" .../&gt;<br/>
+   *         &lt;f:subview id="yyy"><br/>
+   *            &lt;tr:inputColor id="sic1" chooseId="::cp1" .../&gt;<br/>
+   *         &lt;/f:subview&gt;<br/>
+   *      &lt;/f:subview&gt;
+   *   &lt;/f:subview&gt;<br/>
+   * </p>
+   * <p>
    * The 'from' component is the inputColor component.
    * The 'relativeId' is "::cp1". ('::' pops up one naming container)
    * The return value is 'aaa:xxx:cp1' when
    * the clientId of the 'xxx' component is 'aaa:xxx'.
-   * 
+   *
    * </p>
    * <p>
    * It does not assume that the target component can be located, although it does
@@ -142,8 +143,8 @@
    * A relativeId starting with '::' pops out of the 'from' component's
    * naming container. If the 'from' component is a naming container, then
    * '::' will pop out of the 'from' component itself. A relativeId with ':::' pops up two
naming containers, etc.
-   * ComponentUtils.findRelativeComponent finds and returns the component, whereas
-   * this method returns a relativeId that can be used during renderering 
+   * UIXComponent.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.
    * </p>
    * @param context
@@ -151,9 +152,8 @@
    * @param scopedId the relative id path from the 'from' component to the
    *                 component to find
    * @return the clientId for the 'relative' component.
-   * @see ComponentUtils#findRelativeComponent
+   * @see UIXComponent#findRelativeComponent(UIComponent, String)
    * @see javax.faces.component.UIComponent#findComponent
-
    */
   public static String getRelativeId(
     FacesContext context,
@@ -161,69 +161,30 @@
     String       scopedId)
   {
     if (from == null)
-        return null;
-    
+      return null;
+
     if ((scopedId == null) || (scopedId.length() == 0))
       return null;
 
-    // Figure out how many colons
-    int colonCount = _getColonCount(scopedId);
+    // Because a component may override findComponent and do something non-standard with
+    // the ID, we cannot make any assumptions of the client ID from the scopedId
+    UIComponent component = UIXComponent.findRelativeComponent(from, scopedId);
 
-    // 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 scopedId.substring(1);
-    if (colonCount == 0 && !(from instanceof NamingContainer))
-    {
-      // we do it the fast way if there 
-      // are no colons and the from isn't a NamingContainer.
-      // the reason is this use case hasn't changed between the previous
-      // logic and the current logic for finding the component, so it
-      // is already backward compatible, and therefore we don't have to 
-      // call the findComponent code for backward compatibility.
-      return _getRelativeId(context, from, scopedId, colonCount);
-    }
-    
-    // 
-    // 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, scopedId);
-    if (component == null && from instanceof NamingContainer)
-    {
-      component = ComponentUtils.findRelativeComponent(from.getParent(), scopedId);
-      if (component != null)
-      {
-        _LOG.warning("DEPRECATED_RELATIVE_ID_SYNTAX", 
-          new Object[] {scopedId, from});
-      }
-    }
-    
-    // the component wasn't found, but go ahead and return something smart
-    if (component == null)
-    {
-      return _getRelativeId(context, from, scopedId, colonCount);
-    }
-    else
+    if (component != null)
     {
       return component.getClientId(context);
     }
 
+    // the component wasn't found, but go ahead and return something smart
+    return _getRelativeId(context, from, scopedId, _getColonCount(scopedId));
   }
 
-
   // This does NOT use findComponent
-  // ComponentUtils.findRelativeComponent finds the component, whereas
-  // this method returns a relativeId that can be used during renderering 
+  // UIXComponent.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 
+  // 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,
@@ -231,16 +192,14 @@
     String       relativeId,
     int          colonCount)
   {
-
-
     if (colonCount == 1)
       return relativeId.substring(1);
     else if (colonCount > 1)
     {
       relativeId = relativeId.substring(colonCount);
     }
-      
-    // if the component is not a NamingContainer, then we need to 
+
+    // if the component is not a NamingContainer, then we need to
     // get the component's naming container and set this as the 'from'.
 
     if (!(from instanceof NamingContainer))
@@ -263,11 +222,8 @@
       return (from.getClientId(context) +
               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
@@ -286,7 +242,7 @@
 
     return null;
   }
-  
+
   // Figure out how many colons
   private static int _getColonCount(String relativeId)
   {
@@ -300,7 +256,7 @@
     }
     return colonCount;
   }
-  static private final TrinidadLogger _LOG =
-    TrinidadLogger.createTrinidadLogger(RenderUtils.class);
 
+  //static private final TrinidadLogger _LOG =
+  //  TrinidadLogger.createTrinidadLogger(RenderUtils.class);
 }

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
(original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ComponentUtils.java
Wed Nov 11 22:50:04 2009
@@ -325,14 +325,14 @@
   }
 
   /**
-   * @deprecated Use {@link UIXComponent#findComponent(UIComponent, String)} instead
+   * @deprecated Use {@link UIXComponent#findRelativeComponent(UIComponent, String)} instead
    */
   @Deprecated
   public static UIComponent findRelativeComponent(
     UIComponent from,
     String      scopedId)
   {
-    return UIXComponent.findComponent(from, scopedId);
+    return UIXComponent.findRelativeComponent(from, scopedId);
   }
 
   /**

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java
(original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/render/RenderUtilsTest.java
Wed Nov 11 22:50:04 2009
@@ -20,6 +20,7 @@
 
 
 import javax.faces.component.NamingContainer;
+import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.render.Renderer;
 
@@ -62,22 +63,22 @@
       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
   {
 
-    
+
     protected Renderer getRenderer(FacesContext context)
     {
       return null;
@@ -89,34 +90,36 @@
   @SuppressWarnings("unchecked")
   public void testButtonAndNamingContainerSiblings()
   {
-      // 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);
-    
+    // rootPanel
+    //     button1
+    //     table1
+    UIViewRoot viewRoot = new UIViewRoot();
+    TestUIXPanel button1 = new TestUIXPanel();
+    button1.setId("commandButton1");
+    TestNamingContainer table1 = new TestNamingContainer();
+    table1.setId("table1");
+    TestUIXPanel rootPanel = new TestUIXPanel();
+    viewRoot.getChildren().add(rootPanel);
+    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);
+
     relativeId =
       RenderUtils.getRelativeId(null, button1, ":table1");
-    assertEquals("table1", relativeId);
-    
+    assertEquals("table1_Client", 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);
-    
+
     relativeId =
       RenderUtils.getRelativeId(null, table1, ":commandButton1");
     assertEquals("commandButton1", relativeId);
@@ -126,13 +129,13 @@
     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
+
+    // backward compatibility removed test -- this should no longer be found as the
+    // deprecated syntax has been removed
     relativeId =
       RenderUtils.getRelativeId(null, table1, "commandButton1");
-    assertEquals("commandButton1", relativeId);
-       
+    assertEquals("table1_Client:commandButton1", relativeId);
+
     // backward compatibility test -- this was the old syntax for children to the table.
     relativeId =
       RenderUtils.getRelativeId(null, table1, "table1:tableChildId");
@@ -150,35 +153,40 @@
   @SuppressWarnings("unchecked")
   public void testRelativeSearch()
   {
+    // set up component hierarchy
+    UIViewRoot viewRoot = new UIViewRoot();
+    UIXForm form = new UIXForm();
+    viewRoot.getChildren().add(form);
+    form.setId("formId");
+    TestNamingContainer ncRoot = new TestNamingContainer();
+    ncRoot.setId("ncRoot");
+    TestUIXPanel button1 = new TestUIXPanel();
+    button1.setId("button1");
+    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 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(nc1);
+    nc1.getChildren().add(inputA);
+    nc1.getChildren().add(panel1);
+    panel1.getChildren().add(input1);
 
-
-      // set up component hierarchy
-      UIXForm form = new UIXForm(); form.setId("formId");
-      TestNamingContainer ncRoot = new TestNamingContainer(); ncRoot.setId("ncRoot");
-      TestUIXPanel button1 = new TestUIXPanel();
-      button1.setId("button1");
-      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 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(nc1);
-      nc1.getChildren().add(inputA);
-      nc1.getChildren().add(panel1);
-      panel1.getChildren().add(input1);
-      
     /*<f:subview id="ncRoot">
      *  <commandButton1>
      *  <commandButton2>
@@ -186,50 +194,41 @@
      *     <tr:inputText id="inputA" pT="::commandButton1"/>
            <tr:panelGroupLayout>
              <tr:inputText
-             id="input1"
-             for="::commandButton1"/>
+               id="input1"
+               for="::commandButton1"/>
            </tr:panelGroupLayout>
           </f:subview>
        </f:subview>
        rootButton
      */
-      
+
     String relativeId =
       RenderUtils.getRelativeId(null, input1, "::button1");
     // new way should pop OUT of ONE naming container and will find it
     assertEquals("ncRoot:button1", relativeId);
 
-    
-    relativeId =
-      RenderUtils.getRelativeId(null, input1, ":::button1");
+    relativeId = RenderUtils.getRelativeId(null, input1, ":::button1");
     // 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);
-
+    assertEquals("button1", relativeId);
 
-    relativeId =
-      RenderUtils.getRelativeId(null, input1, "randomPeer");
+    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");
+
+    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");
+    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");
+    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
@@ -237,25 +236,16 @@
     // 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");
+    relativeId = RenderUtils.getRelativeId(null, input1, "::::rootButton");
     // new way should pop OUT of ALL NCs and will find it.
     assertEquals("rootButton", relativeId);
-    
 
-    
-    relativeId =
-      RenderUtils.getRelativeId(null, input1, "::::button1");
+    relativeId = RenderUtils.getRelativeId(null, input1, "::::button1");
     // new way should return this
     assertEquals("button1", relativeId);
-    
-    relativeId =
-      RenderUtils.getRelativeId(null, input1, ":::::button1");
+
+    relativeId = RenderUtils.getRelativeId(null, input1, ":::::button1");
     assertEquals("button1", relativeId);
   }
-
-
-
 }

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java
(original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/FindRelativeComponentTest.java
Wed Nov 11 22:50:04 2009
@@ -18,27 +18,28 @@
  */
 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 javax.faces.component.UIViewRoot;
 
 import junit.framework.Test;
+import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.apache.myfaces.trinidad.component.UIXCommand;
+import org.apache.myfaces.trinidad.component.UIXComponent;
 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());
@@ -50,99 +51,96 @@
     super(testName);
   }
 
-  static private class TestNamingContainer extends UIXPanel
-                                           implements NamingContainer
+  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");
 
-      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);
+    UIViewRoot viewRoot = new UIViewRoot();
+    UIXPanel rootPanel = new UIXPanel();
+    rootPanel.getChildren().add(button1);
+    rootPanel.getChildren().add(button2);
+    viewRoot.getChildren().add(rootPanel);
+
+    UIComponent cmp =
+        UIXComponent.findRelativeComponent(button2, "commandButton1");
+    // old and new are the same
+    assertEquals(button1, cmp);
 
-    
+    cmp = UIXComponent.findRelativeComponent(button2, "::::::commandButton1");
+    // old and new are the same
+    assertEquals(button1, cmp);
   }
-    
+
   // 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");
+    UIViewRoot viewRoot = new UIViewRoot();
+
+    // 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);
+    viewRoot.getChildren().add(rootPanel);
+
+    UIComponent cmp =
+      UIXComponent.findRelativeComponent(table1,"::commandButton1");
+     // new & old (because  in old it starts from the viewRoot)
+    assertEquals(button1, cmp);
+
+    cmp = UIXComponent.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 = UIXComponent.findRelativeComponent(button1, "table1");
     assertEquals(table1, cmp);
-    
-    cmp = ComponentUtils.findRelativeComponent(button1, "tableChildId");
+
+    cmp = UIXComponent.findRelativeComponent(button1, "tableChildId");
     assertEquals(null, cmp);
-    
-    cmp = ComponentUtils.findRelativeComponent(button1, "table1:tableChildId");
+
+    cmp = UIXComponent.findRelativeComponent(button1, "table1:tableChildId");
     assertEquals(tableChild, cmp);
-    
-    cmp = ComponentUtils.findRelativeComponent(table1, "tableChildId");
+
+    cmp = UIXComponent.findRelativeComponent(table1, "tableChildId");
     assertEquals(tableChild, cmp);
-    
-    cmp = ComponentUtils.findRelativeComponent(tableChild, "table1");
+
+    cmp = UIXComponent.findRelativeComponent(tableChild, "table1");
     assertEquals(table1, cmp);
-    
-    cmp = ComponentUtils.findRelativeComponent(tableChild, ":commandButton1");
+
+    cmp = UIXComponent.findRelativeComponent(tableChild, ":commandButton1");
     assertEquals(button1, cmp);
-    
-    cmp = ComponentUtils.findRelativeComponent(tableChild, ":::commandButton1");
+
+    cmp = UIXComponent.findRelativeComponent(tableChild, ":::commandButton1");
     assertEquals(button1, cmp);
-    
-    cmp = ComponentUtils.findRelativeComponent(tableChild, "::commandButton1");   
-    assertEquals(button1, cmp); // new way
-    //assertEquals(null, cmp); // old way
-    
 
+    cmp = UIXComponent.findRelativeComponent(tableChild, "::commandButton1");
+    assertEquals(button1, cmp); // new way
   }
-    
-
 
   @SuppressWarnings("unchecked")
   public void testRelativeSearch()
@@ -153,7 +151,7 @@
      *     <f:subview id="nc1">
      *     <tr:inputText id="inputA" pT="::commandButton1"/>
            <tr:panelGroupLayout>
-             <tr:inputText 
+             <tr:inputText
              id="input1"
              partialTriggers="::commandButton1"/>
            </tr:panelGroupLayout>
@@ -161,53 +159,44 @@
        </f:subview>
      */
 
+    UIViewRoot viewRoot = new UIViewRoot();
+
     // 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);
+
+    viewRoot.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");  
+    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
-    
-    
+      UIXComponent.findRelativeComponent(input1,":::commandButton1");
+    assertEquals(null, cmp);
+
+    cmp = UIXComponent.findRelativeComponent(input1, "::::ncRoot:commandButton1");
+    assertEquals(button1, cmp);
+
     // 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    
- 
-  }
-
+    cmp = UIXComponent.findRelativeComponent(inputA, ":::commandButton1");
+    assertEquals(null, cmp);
 
+    cmp = UIXComponent.findRelativeComponent(inputA, "::ncRoot:commandButton1");
+    assertEquals(button1, cmp);
+  }
 }
 

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/pom.xml?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/pom.xml (original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/pom.xml Wed Nov 11 22:50:04 2009
@@ -135,6 +135,10 @@
           <resourceRoots>
             <resourceRoot>src/main/javascript/</resourceRoot>
           </resourceRoots>
+          <projectHasTests>true</projectHasTests>
+          <testSourceRoots>
+            <file>${project.basedir}/src/test</file>
+          </testSourceRoots>
         </configuration>
       </plugin>
       <plugin>

Modified: myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=835112&r1=835111&r2=835112&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
(original)
+++ myfaces/trinidad/branches/ar_Issue1633/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
Wed Nov 11 22:50:04 2009
@@ -58,7 +58,6 @@
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.render.CoreRenderer;
 import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
-import org.apache.myfaces.trinidad.util.ComponentUtils;
 import org.apache.myfaces.trinidad.util.ExternalContextUtils;
 import org.apache.myfaces.trinidad.util.TransientHolder;
 import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
@@ -525,7 +524,7 @@
     }
     for (String target : targets)
     {
-      UIComponent component = ComponentUtils.findRelativeComponent(from, target);
+      UIComponent component = UIXComponent.findRelativeComponent(from, target);
       if (component != null)
       {
         addPartialTarget(component);
@@ -558,24 +557,7 @@
     {
       String trigger = triggers[i];
 
-
-      UIComponent master = ComponentUtils.findRelativeComponent(listener, trigger);
-
-      boolean deprecatedFind = false;
-
-      if (master == null)
-      {
-        UIComponent from = listener;
-        // backward compatible code
-        // The old rule is "if the component is a naming container, search relative
-        // to the parent; otherwise, search relative to the component."
-        if (listener instanceof NamingContainer)
-        {
-          from = listener.getParent();
-          master = ComponentUtils.findRelativeComponent(from, trigger);
-          deprecatedFind = true;
-        }
-      }
+      UIComponent master = UIXComponent.findRelativeComponent(listener, trigger);
 
       if (master == null)
       {
@@ -583,14 +565,6 @@
       }
       else
       {
-        // if we found this with the deprecated method,
-        // then warn the user to change their syntax.
-        if (deprecatedFind)
-        {
-          _LOG.warning("DEPRECATED_TRIGGER_SYNTAX",
-            new Object[] {trigger, listener});
-        }
-
         // Get the set of listeners on this trigger and add this component.
         Set<UIComponent> listeners = pl.get(master);
         if (listeners == null)
@@ -803,9 +777,9 @@
         // listening on it also.
         partialUpdateNotify(listener);
       }
-      
+
       // TRINIDAD-1545
-      // Re-add listeners to the map to accommodate partial targets for different stamps
of 
+      // Re-add listeners to the map to accommodate partial targets for different stamps
of
       // the same component
       pl.put(key, listeners);
     }



Mime
View raw message