You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by dr...@apache.org on 2010/04/29 22:16:10 UTC

svn commit: r939475 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/internal/services/ test/java/org/apache/tapestry5/internal/services/

Author: drobiazko
Date: Thu Apr 29 20:16:10 2010
New Revision: 939475

URL: http://svn.apache.org/viewvc?rev=939475&view=rev
Log:
TAP5-1112: Handle array types in property expressions

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EchoBean.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java?rev=939475&r1=939474&r2=939475&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java Thu Apr 29 20:16:10 2010
@@ -911,7 +911,17 @@ public class PropertyConduitSourceImpl i
 
         private String toSimpleName(Class type)
         {
-            // TODO: handle arrays types
+            if (type.isArray())
+            {
+                Class<?> componentType = type.getComponentType();
+                
+                while (componentType.isArray())
+                {
+                    componentType = componentType.getComponentType();
+                }
+                
+                return InternalUtils.lastTerm(componentType.getName())+"_array";
+            }
             return InternalUtils.lastTerm(type.getName());
         }
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EchoBean.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EchoBean.java?rev=939475&r1=939474&r2=939475&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EchoBean.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/EchoBean.java Thu Apr 29 20:16:10 2010
@@ -25,6 +25,8 @@ public class EchoBean
     private String storedString;
 
     private StringSource stringSource;
+    
+    private Number[][] storedArray;
 
     public StringSource getStringSource()
     {
@@ -75,6 +77,17 @@ public class EchoBean
     {
         this.storedString = storedString;
     }
+    
+
+    public Number[][] getStoredArray()
+    {
+        return storedArray;
+    }
+
+    public void setStoredArray(Number[][] storedArray)
+    {
+        this.storedArray = storedArray;
+    }
 
     public String echoString(String value, String before, String after)
     {
@@ -85,4 +98,9 @@ public class EchoBean
     {
         return input;
     }
+    
+    public Number[][] echoArray(Number[][] input)
+    {
+        return input;
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java?rev=939475&r1=939474&r2=939475&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImplTest.java Thu Apr 29 20:16:10 2010
@@ -380,6 +380,21 @@ public class PropertyConduitSourceImplTe
 
         assertListsEquals(l, new Long(1), new Double(2.0), "Bart");
     }
+    
+    @Test
+    public void arrays_as_method_argument()
+    {
+        PropertyConduit conduit = source.create(EchoBean.class, "echoArray(storedArray)");
+        EchoBean bean = new EchoBean();
+
+        bean.setStoredArray(new Number[][]{ new Integer[] {1, 2}, new Double[] {3.0, 4.0}});
+
+        Number[][] array = (Number[][]) conduit.get(bean);
+
+        assertArraysEqual(array[0], 1, 2);
+        assertArraysEqual(array[1], 3.0, 4.0);
+    }
+    
 
     @Test
     public void not_operator()