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 2007/09/08 17:29:51 UTC

svn commit: r573856 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry/internal/services/ tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ tapestry-core/src/test/java/org/apache/tapestry/internal/bind...

Author: hlship
Date: Sat Sep  8 08:29:50 2007
New Revision: 573856

URL: http://svn.apache.org/viewvc?rev=573856&view=rev
Log:
TAPESTRY-1737: When a property name in a property expression is not valid, the exception message should list the available property names

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PropertyConduitSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/PropBindingFactoryTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PropertyConduitSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PropertyConduitSourceImpl.java?rev=573856&r1=573855&r2=573856&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PropertyConduitSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PropertyConduitSourceImpl.java Sat Sep  8 08:29:50 2007
@@ -30,6 +30,7 @@
 import org.apache.tapestry.ioc.services.ClassFab;
 import org.apache.tapestry.ioc.services.ClassFabUtils;
 import org.apache.tapestry.ioc.services.ClassFactory;
+import org.apache.tapestry.ioc.services.ClassPropertyAdapter;
 import org.apache.tapestry.ioc.services.MethodSignature;
 import org.apache.tapestry.ioc.services.PropertyAccess;
 import org.apache.tapestry.ioc.services.PropertyAdapter;
@@ -133,7 +134,7 @@
         final Method readMethod = buildGetter(rootClass, classFab, expression, terms);
         final Method writeMethod = buildSetter(rootClass, classFab, expression, terms);
 
-        // A conduit is either readable or writeable, otherwise there will already have been
+        // A conduit is either readable or writable, otherwise there will already have been
         // an error about unknown method name or property name.
 
         Class propertyType = readMethod != null ? readMethod.getReturnType() : writeMethod
@@ -326,11 +327,15 @@
     {
         if (term.endsWith(PARENS)) return null;
 
-        PropertyAdapter adapter = _access.getAdapter(activeType).getPropertyAdapter(term);
+        ClassPropertyAdapter classAdapter = _access.getAdapter(activeType);
+        PropertyAdapter adapter = classAdapter.getPropertyAdapter(term);
 
         if (adapter == null)
-            throw new RuntimeException(ServicesMessages
-                    .noSuchProperty(activeType, term, expression));
+            throw new RuntimeException(ServicesMessages.noSuchProperty(
+                    activeType,
+                    term,
+                    expression,
+                    classAdapter.getPropertyNames()));
 
         return adapter.getWriteMethod();
     }
@@ -364,11 +369,15 @@
             return method;
         }
 
-        PropertyAdapter adapter = _access.getAdapter(activeType).getPropertyAdapter(term);
+        ClassPropertyAdapter classAdapter = _access.getAdapter(activeType);
+        PropertyAdapter adapter = classAdapter.getPropertyAdapter(term);
 
         if (adapter == null)
-            throw new RuntimeException(ServicesMessages
-                    .noSuchProperty(activeType, term, expression));
+            throw new RuntimeException(ServicesMessages.noSuchProperty(
+                    activeType,
+                    term,
+                    expression,
+                    classAdapter.getPropertyNames()));
 
         Method m = adapter.getReadMethod();
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java?rev=573856&r1=573855&r2=573856&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ServicesMessages.java Sat Sep  8 08:29:50 2007
@@ -343,13 +343,15 @@
                 propertyExpression);
     }
 
-    static String noSuchProperty(Class targetClass, String propertyName, String propertyExpression)
+    static String noSuchProperty(Class targetClass, String propertyName, String propertyExpression,
+            Collection<String> propertyNames)
     {
         return MESSAGES.format(
                 "no-such-property",
                 targetClass.getName(),
                 propertyName,
-                propertyExpression);
+                propertyExpression,
+                InternalUtils.joinSorted(propertyNames));
     }
 
     static String writeOnlyProperty(String propertyName, Class clazz, String propertyExpression)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties?rev=573856&r1=573855&r2=573856&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/internal/services/ServicesStrings.properties Sat Sep  8 08:29:50 2007
@@ -68,7 +68,7 @@
 missing-application-state-persistence-strategy=No application state persistence strategy is available with name '%s'. Available strategies: %s.
 method-is-void=Method '%s' returns void (in class %s, within property expression '%s').
 method-not-found=No public method '%s' in class %s (within property expression '%s').
-no-such-property=Class %s does not contain a property named '%s' (within property expression '%s').
+no-such-property=Class %s does not contain a property named '%s' (within property expression '%s').  Available properties: %s.
 write-only-property=Property '%s' of class %s (within property expression '%s') is not readable (it has no read accessor method).
 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). \

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/PropBindingFactoryTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/PropBindingFactoryTest.java?rev=573856&r1=573855&r2=573856&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/PropBindingFactoryTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/bindings/PropBindingFactoryTest.java Sat Sep  8 08:29:50 2007
@@ -400,7 +400,8 @@
         {
             assertEquals(
                     ex.getMessage(),
-                    "Class org.apache.tapestry.internal.bindings.StringHolder does not contain a property named \'missingProperty\' (within property expression \'stringHolder.missingProperty.terminalProperty\').");
+                    "Class org.apache.tapestry.internal.bindings.StringHolder does not contain a property named \'missingProperty\' "
+                            + "(within property expression \'stringHolder.missingProperty.terminalProperty\').  Available properties: value.");
             assertSame(ex.getLocation(), l);
         }
 
@@ -541,7 +542,9 @@
         {
             assertEquals(
                     ex.getMessage(),
-                    "Class org.apache.tapestry.internal.bindings.TargetBean does not contain a property named \'missingProperty\' (within property expression \'missingProperty\').");
+                    "Class org.apache.tapestry.internal.bindings.TargetBean does not contain a property named \'missingProperty\' "
+                            + "(within property expression \'missingProperty\').  "
+                            + "Available properties: class, componentResources, intValue, objectValue, readOnly, stringHolder, writeOnly.");
             assertSame(ex.getLocation(), l);
         }
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java?rev=573856&r1=573855&r2=573856&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/ClassPropertyAdapter.java Sat Sep  8 08:29:50 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -21,7 +21,7 @@
  * <p>
  * Only provides access to <em>simple</em> properties. Indexed properties are ignored.
  * <p>
- * When acessing properties by name, the case of the name is ignored.
+ * When accessing properties by name, the case of the name is ignored.
  */
 public interface ClassPropertyAdapter
 {