You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2009/02/15 18:41:20 UTC
svn commit: r744706 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/pageload/ test/app1/
test/java/org/apache/tapestry5/integration/
test/java/org/apache/tapestry5/integration/app1/components/
test/java/org/apa...
Author: hlship
Date: Sun Feb 15 17:41:19 2009
New Revision: 744706
URL: http://svn.apache.org/viewvc?rev=744706&view=rev
Log:
TAP5-487: Easier way to expose parameters of an embedded component in a containing component
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/EmbeddedComponentTypeConflict.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PublishDuplicateNameDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/EmbeddedComponentTypeConflict.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PublishDuplicateNameDemo.java
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.tml
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/ComponentAssemblerImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java
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/pageload/ComponentAssemblerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/ComponentAssemblerImpl.java?rev=744706&r1=744705&r2=744706&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/ComponentAssemblerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/ComponentAssemblerImpl.java Sun Feb 15 17:41:19 2009
@@ -265,7 +265,7 @@
if (embeddedModel != null)
{
- ComponentModel embeddedComponentModel = instantiatorSource.getInstantiator(componentClassName).getModel();
+ // ComponentModel embeddedComponentModel = instantiatorSource.getInstantiator(componentClassName).getModel();
for (String publishedParameterName : embeddedModel.getPublishedParameters())
{
@@ -274,8 +274,11 @@
if (existingEmbeddedId != null)
{
String message = String.format(
- "Parameter '%s' can not be published by embedded component '%s' as it has already been published by embedded component '%s'.",
- publishedParameterName, embedded, existingEmbeddedId);
+ "Parameter '%s' of embedded component '%s' can not be published as a parameter of component %s, as it has previously been published by embedded component '%s'.",
+ publishedParameterName,
+ embeddedId,
+ instantiator.getModel().getComponentClassName(),
+ existingEmbeddedId);
throw new TapestryException(message, location, null);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java?rev=744706&r1=744705&r2=744706&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/pageload/PageLoaderImpl.java Sun Feb 15 17:41:19 2009
@@ -198,7 +198,11 @@
if (result == null)
{
+ // There's a window here where two threads may create the same assembler simultaneously;
+ // the extra assembler will be discarded.
+
result = createAssembler(className, locale);
+
cache.put(key, result);
}
@@ -218,8 +222,8 @@
ComponentAssembler assembler = new ComponentAssemblerImpl(this, instantiatorSource, componentClassResolver,
instantiator, resources, locale);
- // "Program" the assembler by adding actions to it. The actions execute every time a new page instance
- // is needed.
+ // "Program" the assembler by adding actions to it. The actions interact with a
+ // PageAssembly object (a fresh one for each new page being created).
programAssembler(assembler, template);
@@ -806,12 +810,6 @@
if (containerBinding == null) return;
- String description = String.format("InheritedBinding[parameter %s %s (inherited from %s of %s)]",
- parameterName,
- embedded.getCompleteId(),
- containerParameterName,
- container.getCompleteId());
-
// This helps with debugging, and re-orients any thrown exceptions
// to the location of the inherited binding, rather than the container component's
// binding.
@@ -916,7 +914,7 @@
{
ComponentResources resources = pageAssembly.activeElement.peek().getComponentResources();
- // TODO: Add composably
+ // TODO: Add composability
RenderCommand command = elementFactory.newExpansionElement(resources, token);
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/EmbeddedComponentTypeConflict.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/EmbeddedComponentTypeConflict.tml?rev=744706&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/EmbeddedComponentTypeConflict.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/EmbeddedComponentTypeConflict.tml Sun Feb 15 17:41:19 2009
@@ -0,0 +1,6 @@
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ xmlns:p="tapestry:parameter">
+
+ <input t:type="passwordfield" t:id="input"/>
+
+</t:border>
\ 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=744706&r1=744705&r2=744706&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Index.tml Sun Feb 15 17:41:19 2009
@@ -97,7 +97,17 @@
<a href="DuplicateIds">Duplicate IDs</a>
-- demo two components declared with the same ID
</li>
+ <li>
+ <a href="PublishDuplicateNameDemo">Duplicate Published Parameter Name</a>
+ -- demo error checking for the same parameter name published from two different
+ embedded components
+ </li>
+ <li>
+ <a href="EmbeddedComponentTypeConflict">Embedded Component Type Conflict
+ </a>
+ -- error checking for conflict between @Component.type and t:type.
+ </li>
</ul>
-</html>
+</html>
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PublishDuplicateNameDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PublishDuplicateNameDemo.tml?rev=744706&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PublishDuplicateNameDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PublishDuplicateNameDemo.tml Sun Feb 15 17:41:19 2009
@@ -0,0 +1,4 @@
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ xmlns:p="tapestry:parameter">
+ <t:badPublishDuplicate/>
+</t:border>
\ No newline at end of file
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=744706&r1=744705&r2=744706&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 Sun Feb 15 17:41:19 2009
@@ -2550,4 +2550,27 @@
assertText("p3-number", "6");
assertText("p3-value", "{passed to publish1.value}");
}
-}
+
+ /**
+ * TAP5-487
+ */
+ public void conflicting_published_parameter_names_within_same_component()
+ {
+ start("Duplicate Published Parameter Name");
+
+ assertTextPresent(
+ "Parameter 'value' of embedded component 'passwordfield' can not be published as a parameter of " +
+ "component org.apache.tapestry5.integration.app1.components.BadPublishDuplicate, " +
+ "as it has previously been published by embedded component 'textfield'.");
+ }
+
+ public void embedded_type_conflict()
+ {
+ start("Embedded Component Type Conflict");
+
+ assertTextPresent(
+ "Embedded component 'input' provides a type attribute in the template ('passwordfield') " +
+ "as well as in the component class ('textfield'). You should not provide a type attribute in " +
+ "the template when defining an embedded component within the component class.");
+ }
+}
\ No newline at end of file
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.java?rev=744706&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.java Sun Feb 15 17:41:19 2009
@@ -0,0 +1,30 @@
+// Copyright 2009 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.components;
+
+import org.apache.tapestry5.annotations.Component;
+import org.apache.tapestry5.corelib.components.PasswordField;
+import org.apache.tapestry5.corelib.components.TextField;
+
+public class BadPublishDuplicate
+{
+ @Component(publishParameters = "value")
+ private TextField textField;
+
+ // Can't do this: have a duplicate published parameter:
+
+ @Component(publishParameters = "value")
+ private PasswordField passwordField;
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/EmbeddedComponentTypeConflict.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/EmbeddedComponentTypeConflict.java?rev=744706&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/EmbeddedComponentTypeConflict.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/EmbeddedComponentTypeConflict.java Sun Feb 15 17:41:19 2009
@@ -0,0 +1,24 @@
+// Copyright 2009 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.Field;
+import org.apache.tapestry5.annotations.Component;
+
+public class EmbeddedComponentTypeConflict
+{
+ @Component(type = "textfield")
+ private Field input;
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PublishDuplicateNameDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PublishDuplicateNameDemo.java?rev=744706&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PublishDuplicateNameDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PublishDuplicateNameDemo.java Sun Feb 15 17:41:19 2009
@@ -0,0 +1,19 @@
+// Copyright 2009 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;
+
+public class PublishDuplicateNameDemo
+{
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.tml?rev=744706&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/BadPublishDuplicate.tml Sun Feb 15 17:41:19 2009
@@ -0,0 +1,5 @@
+<t:form xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
+ xmlns:p="tapestry:parameter">
+ <input t:id="textfield"/>
+ <input t:id="passwordfield"/>
+</t:form>
\ No newline at end of file