Author: hlship
Date: Tue May 13 17:57:44 2008
New Revision: 656070
URL: http://svn.apache.org/viewvc?rev=656070&view=rev
Log:
TAPESTRY-2305: When Tapestry throws an exception due to an unrecognized
embedded component id, it fails to list the available component ids
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/StructureMessages.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/structure/StructureStrings.properties
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java?rev=656070&r1=656069&r2=656070&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
Tue May 13 17:57:44 2008
@@ -34,10 +34,7 @@
import org.apache.tapestry.runtime.*;
import org.slf4j.Logger;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
+import java.util.*;
/**
* Implements [EMAIL PROTECTED]
org.apache.tapestry.internal.structure.PageElement} and represents a component
within an overall
@@ -801,7 +798,11 @@
.toLowerCase());
if (embeddedElement == null)
- throw new
TapestryException(StructureMessages.noSuchComponent(this, embeddedId), this,
null);
+ {
+ Set<String> ids = children == null ? null : children.keySet();
+
+ throw new
TapestryException(StructureMessages.noSuchComponent(this, embeddedId, ids),
this, null);
+ }
return embeddedElement;
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/StructureMessages.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/StructureMessages.java?rev=656070&r1=656069&r2=656070&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/StructureMessages.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/StructureMessages.java
Tue May 13 17:57:44 2008
@@ -20,6 +20,7 @@
import java.util.Collection;
import java.util.List;
+import java.util.Set;
final class StructureMessages
{
@@ -35,9 +36,10 @@
.getComponentResources().getComponentModel().getComponentClassName());
}
- static String noSuchComponent(ComponentPageElement parent, String
embeddedId)
+ static String noSuchComponent(ComponentPageElement parent, String
embeddedId, Set<String> components)
{
- return MESSAGES.format("no-such-component", parent.getCompleteId(),
embeddedId);
+ return MESSAGES.format("no-such-component", parent.getCompleteId(),
embeddedId,
+ InternalUtils.joinSorted(components));
}
static String getParameterFailure(String parameterName, String
componentId, Throwable cause)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/structure/StructureStrings.properties
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/structure/StructureStrings.properties?rev=656070&r1=656069&r2=656070&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/structure/StructureStrings.properties
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/structure/StructureStrings.properties
Tue May 13 17:57:44 2008
@@ -13,7 +13,7 @@
# limitations under the License.
missing-parameters=Parameter(s) '%s' are required for %s, but have not been
bound.
-no-such-component=Component %s does not contain an embedded component with id
'%s'.
+no-such-component=Component %s does not contain an embedded component with id
'%s'. Available components: %s.
get-parameter-failure=Failure reading parameter '%s' of component %s: %s
write-parameter-failure=Failure writing parameter '%s' of component %s: %s
missing-mixin-for-parameter=Component %s does not contain a mixin named '%s'
(setting parameter '%s').
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java?rev=656070&r1=656069&r2=656070&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
Tue May 13 17:57:44 2008
@@ -371,10 +371,12 @@
TypeCoercer coercer = mockTypeCoercer();
Instantiator ins = newInstantiator(component, model);
+ Instantiator ins2 = newInstantiator(component, model);
replay();
ComponentPageElement cpe = new ComponentPageElementImpl(page, ins,
null);
+ cpe.addEmbeddedElement(new ComponentPageElementImpl(page, cpe,
"nested", null, ins2, null, null));
try
{
@@ -384,7 +386,7 @@
catch (TapestryException ex)
{
assertEquals(ex.getMessage(),
- "Component " + PAGE_NAME + " does not contain an
embedded component with id 'unknown'.");
+ "Component " + PAGE_NAME + " does not contain an
embedded component with id 'unknown'. Available components: nested.");
}
verify();