tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1094829 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
Date Tue, 19 Apr 2011 00:18:43 GMT
Author: hlship
Date: Tue Apr 19 00:18:43 2011
New Revision: 1094829

URL: http://svn.apache.org/viewvc?rev=1094829&view=rev
Log:
TAP5-1508: Change ComponentPageelementImpl to use a simple List of child ComponentPageElements,
rather than a Map or NamedSet

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java?rev=1094829&r1=1094828&r2=1094829&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
Tue Apr 19 00:18:43 2011
@@ -511,7 +511,7 @@ public class ComponentPageElementImpl ex
 
     private BlockImpl bodyBlock;
 
-    private NamedSet<ComponentPageElement> children;
+    private List<ComponentPageElement> children;
 
     private final String elementName;
 
@@ -713,18 +713,19 @@ public class ComponentPageElementImpl ex
     void addEmbeddedElement(ComponentPageElement child)
     {
         if (children == null)
-            children = NamedSet.create();
+            children = CollectionFactory.newList();
 
         String childId = child.getId();
 
-        if (!children.putIfNew(childId, child))
+        for (ComponentPageElement existing : children)
         {
-            ComponentPageElement existing = children.get(childId);
-
-            throw new TapestryException(StructureMessages.duplicateChildComponent(this, childId),
child,
-                    new TapestryException(StructureMessages.originalChildComponent(this,
childId,
-                            existing.getLocation()), existing, null));
+            if (existing.getId().equalsIgnoreCase(childId))
+                throw new TapestryException(StructureMessages.duplicateChildComponent(this,
childId), child,
+                        new TapestryException(StructureMessages.originalChildComponent(this,
childId,
+                                existing.getLocation()), existing, null));
         }
+
+        children.add(child);
     }
 
     public void addMixin(String mixinId, Instantiator instantiator, String... order)
@@ -897,11 +898,31 @@ public class ComponentPageElementImpl ex
 
     public ComponentPageElement getEmbeddedElement(String embeddedId)
     {
-        ComponentPageElement embeddedElement = NamedSet.get(children, embeddedId);
+        ComponentPageElement embeddedElement = null;
+
+        if (children != null)
+        {
+            for (ComponentPageElement child : children)
+            {
+                if (child.getId().equalsIgnoreCase(embeddedId))
+                {
+                    embeddedElement = child;
+                    break;
+                }
+            }
+        }
 
         if (embeddedElement == null)
         {
-            Set<String> ids = NamedSet.getNames(children);
+            Set<String> ids = CollectionFactory.newSet();
+
+            if (children != null)
+            {
+                for (ComponentPageElement child : children)
+                {
+                    ids.add(child.getId());
+                }
+            }
 
             throw new UnknownValueException(String.format("Component %s does not contain
embedded component '%s'.",
                     getCompleteId(), embeddedId), new AvailableValues("Embedded components",
ids));



Mime
View raw message