tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r545817 - in /tapestry/tapestry4/trunk/tapestry-framework/src: java/org/apache/tapestry/binding/ java/org/apache/tapestry/script/ test/org/apache/tapestry/binding/
Date Sun, 10 Jun 2007 00:06:47 GMT
Author: jkuhnert
Date: Sat Jun  9 17:06:46 2007
New Revision: 545817

URL: http://svn.apache.org/viewvc?view=rev&rev=545817
Log:
Fixes TAPESTRY-1554.  Instead of removing the description field just used it as the value
in instances where the value is already a string.  Still need to go back to the exception
reporters + template source line precise rendering to be sure the Location object column attribute
is being used or has enough information to properly highlight the exact section of error.
 More or less - it's better to use the existing line precise stuff and more intelligently
find a good description "on the fly" than storing it permanently in every binding object in
the system.

Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AbstractBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AssetBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/BindingStrings.properties
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/LiteralBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/MessageBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/script/AbstractToken.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestAssetBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestLiteralBinding.java
    tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestMessageBinding.java

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AbstractBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AbstractBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AbstractBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AbstractBinding.java
Sat Jun  9 17:06:46 2007
@@ -30,7 +30,7 @@
 {
     /** @since 4.0 */
 
-    private final String _description;
+    protected final String _description;
 
     /** @since 4.0 */
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AssetBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AssetBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AssetBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/AssetBinding.java
Sat Jun  9 17:06:46 2007
@@ -31,26 +31,23 @@
 {
     private final IComponent _component;
 
-    private final String _assetName;
-
     public AssetBinding(String description, ValueConverter valueConverter, Location location,
             IComponent component, String assetName)
     {
-        super(description, valueConverter, location);
+        super(assetName, valueConverter, location);
 
         Defense.notNull(component, "component");
         Defense.notNull(assetName, "assetName");
 
         _component = component;
-        _assetName = assetName;
     }
 
     public Object getObject()
     {
-        IAsset result = _component.getAsset(_assetName);
+        IAsset result = _component.getAsset(_description);
 
         if (result == null)
-            throw new BindingException(BindingMessages.missingAsset(_component, _assetName),
+            throw new BindingException(BindingMessages.missingAsset(_component, _description),
                     _component, getLocation(), this, null);
 
         return result;

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/BindingStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/BindingStrings.properties?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/BindingStrings.properties
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/BindingStrings.properties
Sat Jun  9 17:06:46 2007
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 convert-object-error=Error converting value for {0}: {1}
-read-only-binding=Binding for {0} ({1}) may not be updated.
+read-only-binding=Binding with value {0} ({1}) may not be updated.
 missing-asset=Component {0} does not contain an asset named ''{1}''.
 listener-method-failure=Exception invoking listener method {0} of component {1}: {2}
 unknown-component=Component with id {0} not found in container component {1}

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/ExpressionBinding.java
Sat Jun  9 17:06:46 2007
@@ -27,7 +27,7 @@
  * Implements a dynamic binding, based on evaluating an expression using an expression language.
  * Tapestry's default expression language is the <a href="http://www.ognl.org/">Object
Graph
  * Navigation Language </a>.
- * 
+ *
  * @see org.apache.tapestry.services.ExpressionEvaluator
  * @author Howard Lewis Ship
  * @since 2.2
@@ -42,12 +42,6 @@
     private final IComponent _root;
 
     /**
-     * The OGNL expression, as a string.
-     */
-
-    private String _expression;
-
-    /**
      * If true, then the binding is invariant.
      */
 
@@ -58,13 +52,13 @@
      */
 
     private Node _parsedExpression;
-    
+
     /**
      * Compiled OGNL expression.
      */
-    
+
     private ExpressionAccessor _accessor;
-    
+
     /**
      * Flag set to true once the binding has initialized.
      */
@@ -107,20 +101,19 @@
      *          Expression cache which does efficient caching of parsed expressions.
      */
     public ExpressionBinding(String description, Location location, ValueConverter valueConverter,
-            IComponent root, String expression, ExpressionEvaluator evaluator,
-            ExpressionCache cache)
+                             IComponent root, String expression, ExpressionEvaluator evaluator,
+                             ExpressionCache cache)
     {
-        super(description, valueConverter, location);
+        super(expression, valueConverter, location);
 
         _root = root;
-        _expression = expression;
         _evaluator = evaluator;
         _cache = cache;
     }
 
     /**
      * Gets the value of the property path, with the assistance of the {@link ExpressionEvaluator}.
-     * 
+     *
      * @throws BindingException
      *             if an exception is thrown accessing the property.
      */
@@ -136,16 +129,15 @@
     {
         try
         {
-            if (_accessor == null && !_writeFailed) {
-                
-                _parsedExpression = (Node)_cache.getCompiledExpression(_root, _expression);
-                
+            if (_accessor == null && !_writeFailed)
+            {
+                _parsedExpression = (Node)_cache.getCompiledExpression(_root, _description);
                 _accessor = _parsedExpression.getAccessor();
             }
-            
+
             if (_accessor != null)
                 return _evaluator.read(_root, _accessor);
-            
+
             return _evaluator.readCompiled(_root, _parsedExpression);
         }
         catch (Throwable t)
@@ -179,9 +171,8 @@
 
         try
         {
-            _parsedExpression = (Node)_cache.getCompiledExpression(_expression);
-            
-            _invariant = _evaluator.isConstant(_expression);
+            _parsedExpression = (Node)_cache.getCompiledExpression(_description);
+            _invariant = _evaluator.isConstant(_description);
         }
         catch (Exception ex)
         {
@@ -191,7 +182,7 @@
 
     /**
      * Updates the property for the binding to the given value.
-     * 
+     *
      * @throws BindingException
      *             if the property can't be updated (typically due to an security problem,
or a
      *             missing mutator method).
@@ -200,21 +191,21 @@
     public void setObject(Object value)
     {
         initialize();
-        
+
         if (_invariant)
             throw createReadOnlyBindingException(this);
-        
+
         try
         {
-            if (_accessor == null) {
-                
+            if (_accessor == null)
+            {
                 _evaluator.writeCompiled(_root, _parsedExpression, value);
 
-                if (!_writeFailed) {
-                    
+                if (!_writeFailed)
+                {    
                     // re-parse expression as compilation may be possible now that it potentially
has a value
                     try {
-                        _parsedExpression = (Node)_cache.getCompiledExpression(_root, _expression);
+                        _parsedExpression = (Node)_cache.getCompiledExpression(_root, _description);
 
                         _accessor = _parsedExpression.getAccessor();
                     } catch (Throwable t) {
@@ -250,10 +241,10 @@
         buffer.append("ExpressionBinding[");
         buffer.append(_root.getExtendedId());
 
-        if (_expression != null)
+        if (_description != null)
         {
             buffer.append(' ');
-            buffer.append(_expression);
+            buffer.append(_description);
         }
 
         buffer.append(']');

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/LiteralBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/LiteralBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/LiteralBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/LiteralBinding.java
Sat Jun  9 17:06:46 2007
@@ -28,23 +28,19 @@
 
 public class LiteralBinding extends AbstractBinding
 {
-    private final String _value;
-
-    public LiteralBinding(String description, ValueConverter valueConverter, Location location,
-            String value)
+    public LiteralBinding(String description, ValueConverter valueConverter,
+                          Location location, String value)
     {
-        super(description, valueConverter, location);
-
-        _value = value;
+        super(value, valueConverter, location);
     }
 
     public Object getObject()
     {
-        return _value;
+        return _description;
     }
 
     public String toString()
     {
-        return "StaticBinding[" + _value + "]";
+        return "StaticBinding[" + _description + "]";
     }
 }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/MessageBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/MessageBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/MessageBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/binding/MessageBinding.java
Sat Jun  9 17:06:46 2007
@@ -33,18 +33,15 @@
 {
     private final IComponent _component;
 
-    private final String _key;
-
     protected MessageBinding(String description, ValueConverter valueConverter, Location
location,
             IComponent component, String key)
     {
-        super(description, valueConverter, location);
+        super(key, valueConverter, location);
 
         Defense.notNull(component, "component");
         Defense.notNull(key, "key");
 
         _component = component;
-        _key = key;
     }
 
     public Object getComponent()
@@ -54,7 +51,7 @@
 
     public String getKey()
     {
-        return _key;
+        return _description;
     }
 
     /**
@@ -63,16 +60,16 @@
 
     public Object getObject()
     {
-        return _component.getMessages().getMessage(_key);
+        return _component.getMessages().getMessage(_description);
     }
 
     public String toString()
     {
-        StringBuffer buffer = new StringBuffer("StringBinding");
+        StringBuffer buffer = new StringBuffer("MessageBinding");
         buffer.append('[');
         buffer.append(_component.getExtendedId());
         buffer.append(' ');
-        buffer.append(_key);
+        buffer.append(_description);
         buffer.append(']');
 
         return buffer.toString();

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/script/AbstractToken.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/script/AbstractToken.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/script/AbstractToken.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/script/AbstractToken.java
Sat Jun  9 17:06:46 2007
@@ -14,13 +14,13 @@
 
 package org.apache.tapestry.script;
 
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.Location;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.Location;
-
 /**
  * Base class for creating tokens which may contain other tokens.
  * 
@@ -74,7 +74,7 @@
 
     /**
      * Evaluates the expression against the session's symbols, using
-     * {@link ExpressionEvaluator#read(Object, String)} and returns the result.
+     * {@link org.apache.tapestry.services.ExpressionEvaluator#read(Object, String)} and
returns the result.
      */
     protected Object evaluate(String expression, ScriptSession session)
     {

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestAssetBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestAssetBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestAssetBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestAssetBinding.java
Sat Jun  9 17:06:46 2007
@@ -14,14 +14,13 @@
 
 package org.apache.tapestry.binding;
 
-import static org.easymock.EasyMock.expect;
-
 import org.apache.hivemind.Location;
 import org.apache.tapestry.BindingException;
 import org.apache.tapestry.IAsset;
 import org.apache.tapestry.IBinding;
 import org.apache.tapestry.IComponent;
 import org.apache.tapestry.coerce.ValueConverter;
+import static org.easymock.EasyMock.expect;
 import org.testng.annotations.Test;
 
 /**
@@ -50,7 +49,7 @@
         assertSame(asset, b.getObject());
 
         assertSame(l, b.getLocation());
-        assertEquals("parameterName", b.getDescription());
+        assertEquals("fred", b.getDescription());
 
         assertSame(component, b.getComponent());
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestExpressionBinding.java
Sat Jun  9 17:06:46 2007
@@ -192,8 +192,7 @@
         }
         catch (BindingException ex)
         {
-            assertEquals(
-                    "Binding for parameter foo (ExpressionBinding[Foo/bar.baz exp]) may not
be updated.",
+            assertEquals("Binding with value exp (ExpressionBinding[Foo/bar.baz exp]) may
not be updated.",
                     ex.getMessage());
         }
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestLiteralBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestLiteralBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestLiteralBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestLiteralBinding.java
Sat Jun  9 17:06:46 2007
@@ -14,15 +14,14 @@
 
 package org.apache.tapestry.binding;
 
-import static org.easymock.EasyMock.expect;
-
-import java.util.Date;
-
 import org.apache.hivemind.Location;
 import org.apache.tapestry.BindingException;
 import org.apache.tapestry.coerce.ValueConverter;
+import static org.easymock.EasyMock.expect;
 import org.testng.annotations.Test;
 
+import java.util.Date;
+
 /**
  * Tests for {@link org.apache.tapestry.binding.LiteralBinding}. It also tests some common
  * behaviors provided by {@link org.apache.tapestry.binding.AbstractBinding}.
@@ -33,7 +32,7 @@
 @Test
 public class TestLiteralBinding extends BindingTestCase
 {
-    public void testGetObject()
+    public void test_Get_Object()
     {
         Location l = fabricateLocation(22);
         ValueConverter vc = newValueConverter();
@@ -43,7 +42,7 @@
         LiteralBinding b = new LiteralBinding("parameter foo", vc, l, "literal-value");
 
         assertSame(l, b.getLocation());
-        assertEquals("parameter foo", b.getDescription());
+        assertEquals(b.getDescription(), "literal-value");
         assertEquals("literal-value", b.getObject());
 
         assertEquals(true, b.isInvariant());
@@ -52,7 +51,7 @@
         verify();
     }
 
-    public void testToString()
+    public void test_To_String()
     {
         Location l = fabricateLocation(22);
         ValueConverter vc = newValueConverter();
@@ -66,7 +65,7 @@
         verify();
     }
 
-    public void testGetObjectWithClass()
+    public void test_Get_Object_With_Class()
     {
         ValueConverter vc = newMock(ValueConverter.class);
         Location l = fabricateLocation(99);
@@ -84,7 +83,7 @@
         verify();
     }
 
-    public void testGetObjectException()
+    public void test_Get_Object_Exception()
     {
         ValueConverter vc = newMock(ValueConverter.class);
         Location location = fabricateLocation(99);
@@ -104,7 +103,7 @@
         }
         catch (BindingException ex)
         {
-            assertEquals("Error converting value for parameter foo: Failure", ex.getMessage());
+            assertEquals(ex.getMessage(), "Error converting value for my-literal: Failure");
             assertSame(innerException, ex.getRootCause());
             assertSame(location, ex.getLocation());
             assertSame(b, ex.getBinding());
@@ -113,7 +112,7 @@
         verify();
     }
 
-    public void testSetObject()
+    public void test_Set_Object()
     {
         Location l = fabricateLocation(22);
         ValueConverter vc = newValueConverter();
@@ -129,9 +128,8 @@
         }
         catch (BindingException ex)
         {
-            assertEquals(
-                    "Binding for parameter foo (StaticBinding[literal-value]) may not be
updated.",
-                    ex.getMessage());
+            assertEquals(ex.getMessage() ,
+                    "Binding with value literal-value (StaticBinding[literal-value]) may
not be updated.");
             assertSame(b, ex.getBinding());
             assertSame(l, ex.getLocation());
         }

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestMessageBinding.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestMessageBinding.java?view=diff&rev=545817&r1=545816&r2=545817
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestMessageBinding.java
(original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/binding/TestMessageBinding.java
Sat Jun  9 17:06:46 2007
@@ -14,12 +14,11 @@
 
 package org.apache.tapestry.binding;
 
-import static org.easymock.EasyMock.expect;
-
 import org.apache.hivemind.Location;
 import org.apache.hivemind.Messages;
 import org.apache.tapestry.IComponent;
 import org.apache.tapestry.coerce.ValueConverter;
+import static org.easymock.EasyMock.expect;
 import org.testng.annotations.Test;
 
 /**
@@ -60,7 +59,7 @@
 
         MessageBinding b = new MessageBinding("param", vc, l, component, "key");
 
-        assertEquals("StringBinding[Foo/bar.baz key]", b.toString());
+        assertEquals("MessageBinding[Foo/bar.baz key]", b.toString());
 
         verify();
     }



Mime
View raw message