You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by km...@apache.org on 2009/02/03 04:28:23 UTC
svn commit: r740200 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/structure/
main/resources/org/apache/tapestry5/internal/structure/ test/app1/
test/java/org/apache/tapestry5/integration/ test/java/org/apache...
Author: kmenard
Date: Tue Feb 3 03:28:23 2009
New Revision: 740200
URL: http://svn.apache.org/viewvc?rev=740200&view=rev
Log:
Initial work on TAP5-181: Highlight duplicated IDs.
Added a new test and wrap original location as cause of duplicate exception.
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DuplicateIds.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DuplicateIds.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/StructureMessages.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/structure/StructureStrings.properties
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.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=740200&r1=740199&r2=740200&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 Feb 3 03:28:23 2009
@@ -662,7 +662,8 @@
ComponentPageElement existing = children.get(childId);
if (existing != null)
- throw new TapestryException(StructureMessages.duplicateChildComponent(this, childId), child, null);
+ throw new TapestryException(StructureMessages.duplicateChildComponent(this, childId), child,
+ new TapestryException(StructureMessages.originalChildComponent(this, childId, existing.getLocation()), existing, null));
children.put(childId, child);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/StructureMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/StructureMessages.java?rev=740200&r1=740199&r2=740200&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/StructureMessages.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/StructureMessages.java Tue Feb 3 03:28:23 2009
@@ -15,6 +15,7 @@
package org.apache.tapestry5.internal.structure;
import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.Location;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
@@ -93,6 +94,11 @@
return MESSAGES.format("duplicate-child-component", container.getCompleteId(), childId);
}
+ static String originalChildComponent(ComponentPageElement container, String childId, Location originalLocation)
+ {
+ return MESSAGES.format("original-child-component", container.getCompleteId(), childId, originalLocation.getLine());
+ }
+
static String duplicateBlock(ComponentPageElement component, String blockId)
{
return MESSAGES.format("duplicate-block", component.getCompleteId(), blockId);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/structure/StructureStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/structure/StructureStrings.properties?rev=740200&r1=740199&r2=740200&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/structure/StructureStrings.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/structure/StructureStrings.properties Tue Feb 3 03:28:23 2009
@@ -29,6 +29,7 @@
and may indicate that a reference to the page (or component within the page) was retained past the end of a request.
duplicate-child-component=Component %s already contains a child component with id '%s'. \
Embedded component ids must be unique (excluding case, which is ignored).
+original-child-component=Component %s declared original child component with id '%s' on line %s.
duplicate-block=Component %s already contains a block with id '%s'. \
Block ids must be unique (excluding case, which is ignored).
field-persist-failure=Error persisting field %s:%s: %s
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DuplicateIds.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DuplicateIds.tml?rev=740200&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DuplicateIds.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DuplicateIds.tml Tue Feb 3 03:28:23 2009
@@ -0,0 +1,19 @@
+<html t:type="border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Duplicate IDs Demo</h1>
+
+ <p>
+ <t:pagelink t:id="index" page="index">Contrived link to index.</t:pagelink>
+ </p>
+
+ <p>
+ Some spacer text to separate the second link with
+ the same ID from the original. This will help
+ illustrate the value in highlighting both locations
+ where a given ID is used.
+ </p>
+
+ <p>
+ <t:pagelink t:id="index" page="index">Link with duplicate ID.</t:pagelink>
+ </p>
+</html>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml?rev=740200&r1=740199&r2=740200&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml Tue Feb 3 03:28:23 2009
@@ -93,6 +93,10 @@
<a href="GetterMethodAlreadyExists">Getter Method Already Exists</a>
-- demo @Property attempting to overwrite an existing getter method
</li>
+ <li>
+ <a href="DuplicateIds">Duplicate IDs</a>
+ -- demo two components declared with the same ID
+ </li>
</ul>
</html>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=740200&r1=740199&r2=740200&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Tue Feb 3 03:28:23 2009
@@ -2525,4 +2525,15 @@
assertTextPresent("Unable to add new method public final java.lang.String getName() as it already exists.");
}
+
+ /**
+ * TAP5-181
+ */
+ public void duplicate_ids_highlight_both_locations()
+ {
+ start("Duplicate IDs");
+
+ assertTextPresent("Component DuplicateIds already contains a child component with id 'index'. Embedded component ids must be unique (excluding case, which is ignored).");
+ assertTextPresent("Component DuplicateIds declared original child component with id 'index' on line 6.");
+ }
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DuplicateIds.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DuplicateIds.java?rev=740200&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DuplicateIds.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DuplicateIds.java Tue Feb 3 03:28:23 2009
@@ -0,0 +1,22 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed 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.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Component;
+import org.apache.tapestry5.corelib.components.BeanEditForm;
+
+public class DuplicateIds
+{
+}