You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by la...@apache.org on 2005/12/01 04:37:12 UTC

svn commit: r350131 - in /struts/action/trunk/src: java/org/apache/struts/util/DynaBeanInterceptor.java test/org/apache/struts/action/TestCGLibDynaActionForm.java

Author: laurieh
Date: Wed Nov 30 19:37:06 2005
New Revision: 350131

URL: http://svn.apache.org/viewcvs?rev=350131&view=rev
Log:
Re-apply changes from r349286, but only generate indexed getter/setter for
array-typed properties (not lists). Also fixed the log instance to be
static and updated the unit test.


Modified:
    struts/action/trunk/src/java/org/apache/struts/util/DynaBeanInterceptor.java
    struts/action/trunk/src/test/org/apache/struts/action/TestCGLibDynaActionForm.java

Modified: struts/action/trunk/src/java/org/apache/struts/util/DynaBeanInterceptor.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/util/DynaBeanInterceptor.java?rev=350131&r1=350130&r2=350131&view=diff
==============================================================================
--- struts/action/trunk/src/java/org/apache/struts/util/DynaBeanInterceptor.java (original)
+++ struts/action/trunk/src/java/org/apache/struts/util/DynaBeanInterceptor.java Wed Nov 30 19:37:06 2005
@@ -45,7 +45,7 @@
  */
 public class DynaBeanInterceptor implements MethodInterceptor, Serializable  {
 
-    private Log log = LogFactory.getLog(DynaBeanInterceptor.class);
+    private static Log log = LogFactory.getLog(DynaBeanInterceptor.class);
 
     /** A lookup table to map method names to the corresponding properties. */
     private Map propertyLookup = new HashMap();
@@ -115,11 +115,11 @@
                 im.add(setter, Constants.TYPES_EMPTY);
 
                 // Create the indexed getter/setter method pair
-                if (dynaProperties[i].isIndexed()) {
-                    Type itype = Type.getType(Integer.class);
+                if (dynaProperties[i].isIndexed() && dynaProperties[i].getType().isArray()) {
+                    Type itype = Type.getType(Integer.TYPE);
                     ttype = Type.getType((type.isArray() ? type.getComponentType() : Object.class));
                     Signature indexGetter = new Signature(getterName, ttype, new Type[] { itype });
-                    Signature indexSetter = new Signature(setterName, Type.VOID_TYPE, new Type[] { ttype, itype });
+                    Signature indexSetter = new Signature(setterName, Type.VOID_TYPE, new Type[] { itype, ttype });
                     im.add(indexGetter, Constants.TYPES_EMPTY);
                     im.add(indexSetter, Constants.TYPES_EMPTY);
                 }
@@ -180,9 +180,9 @@
             if (args.length == 1) {
                 dynaBean.set(property, args[0]);
                 return null;
-            } else if(args.length == 2 && args[1].getClass() == Integer.class) {
-                int index = ((Integer)args[1]).intValue();
-                dynaBean.set(property, index, args[0]);
+            } else if(args.length == 2 && args[0].getClass() == Integer.class) {
+                int index = ((Integer)args[0]).intValue();
+                dynaBean.set(property, index, args[1]);
                 return null;
             } else {
                 return proxy.invokeSuper(obj, args);

Modified: struts/action/trunk/src/test/org/apache/struts/action/TestCGLibDynaActionForm.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/test/org/apache/struts/action/TestCGLibDynaActionForm.java?rev=350131&r1=350130&r2=350131&view=diff
==============================================================================
--- struts/action/trunk/src/test/org/apache/struts/action/TestCGLibDynaActionForm.java (original)
+++ struts/action/trunk/src/test/org/apache/struts/action/TestCGLibDynaActionForm.java Wed Nov 30 19:37:06 2005
@@ -17,17 +17,16 @@
  */
 package org.apache.struts.action;
 
-import java.util.List;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
 import java.beans.BeanInfo;
+import java.beans.IndexedPropertyDescriptor;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
-import java.beans.IndexedPropertyDescriptor;
-import org.apache.commons.beanutils.DynaProperty;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+import org.apache.commons.beanutils.DynaProperty;
 
 /**
  * Suite of unit tests for the
@@ -114,14 +113,13 @@
                 } else {
                     boolean indexedDescriptor = (descriptor instanceof IndexedPropertyDescriptor);
                     if (!(dynaProperty.getType() == descriptor.getPropertyType())) {
-                        // ignore java.util.List - not proper indexed properties
-                        if (!(List.class.isAssignableFrom(dynaProperty.getType()))) {
-                            fail(i+" Descriptor type error: " + dynaProperty.getName() +
-                                 " dyna=" + dynaProperty.getType() +
-                                 " regular=" + descriptor.getPropertyType());
-                        }
+                        fail(i+" Descriptor type error: " + dynaProperty.getName() +
+                             " dyna=" + dynaProperty.getType() +
+                             " regular=" + descriptor.getPropertyType());
                     }
-                    if (!(dynaProperty.isIndexed() == indexedDescriptor)) {
+                    boolean indexed = dynaProperty.isIndexed() && 
+                            dynaProperty.getType().isArray();
+                    if (indexed != indexedDescriptor) {
                         fail(i+" Descriptor index error: " + dynaProperty.getName() +
                              " dyna=" + dynaProperty.isIndexed() +
                              " regular=" + indexedDescriptor);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org