You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/09/23 21:35:27 UTC
svn commit: r1174968 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/internal/services/
main/resources/org/apache/tapestry5/internal/services/
test/java/org/apache/tapestry5/internal/services/
Author: hlship
Date: Fri Sep 23 19:35:27 2011
New Revision: 1174968
URL: http://svn.apache.org/viewvc?rev=1174968&view=rev
Log:
TAP5-845: Informal Parameters are not allowed to have the value "" (the empty string)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BindingSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BindingSourceImplTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BindingSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BindingSourceImpl.java?rev=1174968&r1=1174967&r2=1174968&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BindingSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BindingSourceImpl.java Fri Sep 23 19:35:27 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2009, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 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.
@@ -14,8 +14,6 @@
package org.apache.tapestry5.internal.services;
-import java.util.Map;
-
import org.apache.tapestry5.Binding;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.ioc.Location;
@@ -24,6 +22,8 @@ import org.apache.tapestry5.ioc.internal
import org.apache.tapestry5.services.BindingFactory;
import org.apache.tapestry5.services.BindingSource;
+import java.util.Map;
+
public class BindingSourceImpl implements BindingSource
{
private final Map<String, BindingFactory> factories;
@@ -42,14 +42,16 @@ public class BindingSourceImpl implement
}
public Binding newBinding(String description, ComponentResources container, ComponentResources component,
- String defaultPrefix, String expression, Location location)
+ String defaultPrefix, String expression, Location location)
{
assert InternalUtils.isNonBlank(description);
assert container != null;
assert InternalUtils.isNonBlank(defaultPrefix);
assert component != null;
- if (InternalUtils.isBlank(expression))
- throw new TapestryException(ServicesMessages.emptyBinding(description), location, null);
+
+ // TAP5-845: The expression may be the empty string. This is ok, if it's compatible with
+ // the default prefix (the empty string is not a valid property expression, but is valid
+ // as a literal string, perhaps as an informal parameter).
// Location might be null
@@ -76,10 +78,9 @@ public class BindingSourceImpl implement
try
{
return factory.newBinding(interner.intern(description), container, component, subexpression, location);
- }
- catch (Exception ex)
+ } catch (Exception ex)
{
- throw new TapestryException(ServicesMessages.bindingSourceFailure(expression, ex), location, ex);
+ throw new TapestryException(String.format("Could not convert '%s' into a component parameter binding: %s", expression, InternalUtils.toMessage(ex)), location, ex);
}
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java?rev=1174968&r1=1174967&r2=1174968&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java Fri Sep 23 19:35:27 2011
@@ -14,49 +14,30 @@
package org.apache.tapestry5.internal.services;
-import javassist.CtClass;
import org.apache.tapestry5.internal.structure.ComponentPageElement;
import org.apache.tapestry5.internal.structure.Page;
import org.apache.tapestry5.ioc.Location;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.Resource;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
import org.apache.tapestry5.ioc.services.ClassFabUtils;
import org.apache.tapestry5.runtime.Component;
import org.apache.tapestry5.runtime.RenderCommand;
-import org.apache.tapestry5.services.TransformMethodSignature;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import java.util.Locale;
public class ServicesMessages
{
private static final Messages MESSAGES = MessagesImpl.forClass(ServicesMessages.class);
- public static String duplicateContribution(Object conflict, Class contributionType, Object existing)
- {
- return MESSAGES.format("duplicate-contribution", conflict, contributionType.getName(), existing);
- }
-
public static String markupWriterNoCurrentElement()
{
return MESSAGES.get("markup-writer-no-current-element");
}
- public static String errorAddingMethod(CtClass ctClass, String methodName, Throwable cause)
- {
- return MESSAGES.format("error-adding-method", ctClass.getName(), methodName, cause);
- }
-
- public static String classNotTransformed(String className)
- {
- return MESSAGES.format("class-not-transformed", className);
- }
-
public static String missingTemplateResource(Resource resource)
{
return MESSAGES.format("missing-template-resource", resource);
@@ -67,31 +48,11 @@ public class ServicesMessages
return MESSAGES.format("content-inside-body-not-allowed", location);
}
- public static String methodCompileError(TransformMethodSignature signature, String methodBody, Throwable cause)
- {
- return MESSAGES.format("method-compile-error", signature, methodBody, cause);
- }
-
public static String renderQueueError(RenderCommand command, Throwable cause)
{
return MESSAGES.format("render-queue-error", command, cause);
}
- public static String readOnlyField(String className, String fieldName)
- {
- return MESSAGES.format("read-only-field", className, fieldName);
- }
-
- public static String nonPrivateFields(String className, List<String> names)
- {
- return MESSAGES.format("non-private-fields", className, InternalUtils.joinSorted(names));
- }
-
- public static String bindingSourceFailure(String expression, Throwable cause)
- {
- return MESSAGES.format("binding-source-failure", expression, cause);
- }
-
public static String contextIndexOutOfRange(String methodDescription)
{
return MESSAGES.format("context-index-out-of-range", methodDescription);
@@ -112,16 +73,6 @@ public class ServicesMessages
return MESSAGES.format("component-event-is-aborted", methodDescription);
}
- public static String parameterNameMustBeUnique(String parameterName, String parameterValue)
- {
- return MESSAGES.format("parameter-name-must-be-unique", parameterName, parameterValue);
- }
-
- public static String pageIsDirty(Object page)
- {
- return MESSAGES.format("page-is-dirty", page);
- }
-
public static String componentInstanceIsNotAPage(Component result)
{
return MESSAGES.format("component-instance-is-not-a-page", result.getComponentResources().getCompleteId());
@@ -163,17 +114,6 @@ public class ServicesMessages
return MESSAGES.format("mixins-invalid-without-id-or-type", elementName);
}
- public static String invalidComponentEventResult(Object result, Collection<Class> configuredResultTypes)
- {
- List<String> classNames = CollectionFactory.newList();
-
- for (Class c : configuredResultTypes)
- classNames.add(c.getName());
-
- return MESSAGES.format("invalid-component-event-result", result, ClassFabUtils.toJavaClassName(result
- .getClass()), InternalUtils.joinSorted(classNames));
- }
-
public static String undefinedTapestryAttribute(String elementName, String attributeName,
String allowedAttributeName)
{
@@ -196,11 +136,6 @@ public class ServicesMessages
return MESSAGES.format("request-exception", cause);
}
- public static String componentRecursion(String componentClassName)
- {
- return MESSAGES.format("component-recursion", componentClassName);
- }
-
public static String clientStateMustBeSerializable(Object newValue)
{
return MESSAGES.format("client-state-must-be-serializable", newValue);
@@ -253,33 +188,12 @@ public class ServicesMessages
return MESSAGES.format(messageKey, idValue);
}
- public static String attributeNotAllowed(String elementName)
- {
- return MESSAGES.format("attribute-not-allowed", elementName);
- }
-
- public static String pagePoolExausted(String pageName, Locale locale, int hardLimit)
- {
- return MESSAGES.format("page-pool-exausted", pageName, locale.toString(), hardLimit);
- }
-
public static String noTranslatorForType(Class valueType, Collection<String> typeNames)
{
return MESSAGES.format("no-translator-for-type", ClassFabUtils.toJavaClassName(valueType), InternalUtils
.joinSorted(typeNames));
}
- public static String emptyBinding(String parameterName)
- {
- return MESSAGES.format("parameter-binding-must-not-be-empty", parameterName);
- }
-
-
- public static String forbidInstantiateComponentClass(String className)
- {
- return MESSAGES.format("forbid-instantiate-component-class", className);
- }
-
public static String eventNotHandled(ComponentPageElement element, String eventName)
{
return MESSAGES.format("event-not-handled", eventName, element.getCompleteId());
@@ -290,11 +204,6 @@ public class ServicesMessages
return MESSAGES.format("document-missing-html-root", rootElementName);
}
- public static String addNewMethodConflict(TransformMethodSignature signature)
- {
- return MESSAGES.format("add-new-method-conflict", signature);
- }
-
public static String parameterElementDoesNotAllowAttributes()
{
return MESSAGES.get("parameter-element-does-not-allow-attributes");
@@ -310,16 +219,6 @@ public class ServicesMessages
return MESSAGES.get("literal-conduit-not-updateable");
}
- public static String requestRewriteReturnedNull()
- {
- return MESSAGES.get("request-rewrite-returned-null");
- }
-
- public static String linkRewriteReturnedNull()
- {
- return MESSAGES.get("link-rewrite-returned-null");
- }
-
public static String markupWriterAttributeNameOrValueOmitted(String element, Object[] namesAndValues)
{
return MESSAGES.format("markup-writer-attribute-name-or-value-omitted", element, InternalUtils.join(Arrays
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties?rev=1174968&r1=1174967&r2=1174968&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties Fri Sep 23 19:35:27 2011
@@ -12,28 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-duplicate-contribution=Contribution %s (for type %s) conflicts with existing contribution %s and has been ignored.
markup-writer-no-current-element=This markup writer does not have a current element. \
The current element is established with the first call to element() and is \
maintained across subsequent calls.
-error-adding-method=Error adding method %s to class %s: %s
-class-not-transformed=Class %s was not transformed for use as a component; this can happen if it is an interface, or was not in a package subject to component transformation.
missing-template-resource=Template resource %s does not exist.
content-inside-body-not-allowed=Content inside a Tapestry body element is not allowed (at %s). The content has been ignored.
-method-compile-error=Error compiling method %s (%s): %s
render-queue-error=Render queue error in %s: %s
-read-only-field=Field %s.%s is read-only.
-non-private-fields=Class %s contains field(s) (%s) that are not private. \
- You should change these fields to private, and add accessor methods if needed.
mixins-invalid-without-id-or-type=You may not specify mixins for element <%s> because it does not represent a component (which requires either an id attribute or a type attribute).
-binding-source-failure=Could not convert '%s' into a component parameter binding: %s
page-name-unresolved=Unable to resolve class name %s to a logical page name.
context-index-out-of-range=Method %s has more parameters than there are context values for this component event.
exception-in-method-parameter=Exception in method %s, parameter #%d: %s
component-event-is-aborted=Can not store result from invoking method %s, because an event result value has already been obtained from some other event handler method.
could-not-canonicalize-page-name=Unable to resolve '%s' to a known page name. Available page names: %s.
-parameter-name-must-be-unique=Parameter names are required to be unique. Parameter '%s' already has the value '%s'.
-page-is-dirty=Page %s is dirty, and will be discarded (rather than returned to the page pool).
component-instance-is-not-a-page=Component %s was returned from an event handler method, but is not a page component. The page containing the component will render the client response.
failure-reading-messages=Unable to read message catalog from %s: %s
unknown-asset-prefix=Unknown prefix for asset path '%s'.
@@ -42,12 +32,9 @@ wrong-asset-digest=The asset digest in t
unknown-validator-type=Unknown validator type '%s'. Configured validators are %s.
validator-specification-parse-error=Unexpected character '%s' at position %d of input string: %s
undefined-tapestry-attribute=Element <%s> does not support an attribute named '%s'. The only allowed attribute name is '%s'.
-attribute-not-allowed=Element <%s> does not support any attributes.
parameter-element-name-required=The name attribute of the <parameter> element must be specified.
missing-application-state-persistence-strategy=No application state persistence strategy is available with name '%s'. Available strategies: %s.
request-exception=Processing of request failed with uncaught exception: %s
-component-recursion=The template for component %s is recursive (contains another direct or indirect reference to component %<s). \
- This is not supported (components may not contain themselves).
client-state-must-be-serializable=State persisted on the client must be serializable, but %s does not implement the Serializable interface.
corrupt-client-state=Serialized client state was corrupted. \
This may indicate that too much state is being stored, which can cause the encoded string to be truncated by the client web browser.
@@ -63,18 +50,10 @@ no-markup-from-page-render=Page %s did n
base-class-in-wrong-package=Base class %s (super class of %s) is not in a controlled package and is therefore not valid. You should try moving the class to package %s.
invalid-component-id=Component id '%s' is not valid; component ids must be valid Java identifiers: start with a letter, and consist of letters, numbers and underscores.
invalid-block-id=Block id '%s' is not valid; block ids must be valid Java identifiers: start with a letter, and consist of letters, numbers and underscores.
-page-pool-exausted=The page pool for page '%s' (in locale %s) has been exausted: there are %d instances currently being used and no more can be created. \
- Try increasing the hard limit (symbol tapestry.page-pool.hard-limit) to allow additional instances to be created, \
- or increasing the soft wait (symbol tapestry.page-pool.soft-wait) to trade away some throughput for more efficient use of page instances.
no-translator-for-type=No translator is defined for type %s. Registered types: %s.
-parameter-binding-must-not-be-empty=Parameter '%s' must have a non-empty binding.
-forbid-instantiate-component-class=Component class %s may not be instantiated directly. You should use an @InjectPage or @InjectComponent annotation instead.
event-not-handled=Request event '%s' (on component %s) was not handled; you must provide a matching event handler method in the component or in one of its containers.
document-missing-html-root=The root element of the rendered document was <%s>, not <html>. A root element of <html> is needed when linking JavaScript and stylesheet resources.
-add-new-method-conflict=Unable to add new method %s as it already exists.
parameter-element-does-not-allow-attributes=A block parameter element does not allow any additional attributes. The element name defines the parameter name.
invalid-path-for-library-namespace=The path portion of library namespace URI '%s' is not valid: it must be a simple identifier, or a series of identifiers seperated by slashes.
literal-conduit-not-updateable=Literal values are not updateable.
-request-rewrite-returned-null=URLRewriterRule.process returned null while processing incoming request
-link-rewrite-returned-null=URLRewriterRule.process returned null while processing outbound link.
markup-writer-attribute-name-or-value-omitted=Writing attributes of the element '%s' failed. A attribute name or value is omitted [%s]. Please provide an even number of values, alternating names and values
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BindingSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BindingSourceImplTest.java?rev=1174968&r1=1174967&r2=1174968&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BindingSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/BindingSourceImplTest.java Fri Sep 23 19:35:27 2011
@@ -18,7 +18,6 @@ import org.apache.tapestry5.Binding;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
import org.apache.tapestry5.ioc.Location;
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
import org.apache.tapestry5.ioc.internal.util.TapestryException;
import org.apache.tapestry5.services.BindingFactory;
import org.apache.tapestry5.services.BindingSource;
@@ -26,6 +25,8 @@ import org.testng.annotations.Test;
import java.util.Map;
+import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
+
public class BindingSourceImplTest extends InternalBaseTestCase
{
private final StringInterner interner = new StringInternerImpl();
@@ -166,8 +167,7 @@ public class BindingSourceImplTest exten
{
source.newBinding(description, container, component, defaultPrefix, expression, l);
unreachable();
- }
- catch (TapestryException ex)
+ } catch (TapestryException ex)
{
assertTrue(ex.getMessage().contains(
"Could not convert 'full expression' into a component parameter binding"));
@@ -178,37 +178,4 @@ public class BindingSourceImplTest exten
verify();
}
-
- @Test
- public void empty_parameter_binding()
- {
- BindingFactory factory = mockBindingFactory();
- ComponentResources container = mockComponentResources();
- ComponentResources component = mockComponentResources();
- Location l = mockLocation();
-
- String defaultPrefix = "def";
- String description = "wilma";
- String expression = "";
-
- replay();
-
- Map<String, BindingFactory> map = newMap();
-
- map.put(defaultPrefix, factory);
-
- BindingSource source = new BindingSourceImpl(map, interner);
-
- try
- {
- source.newBinding(description, container, component, defaultPrefix, expression, l);
- }
- catch (TapestryException ex)
- {
- assertEquals(ex.getMessage(), "Parameter 'wilma' must have a non-empty binding.");
- assertSame(ex.getLocation(), l);
- }
-
- verify();
- }
}