You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2007/06/26 13:54:46 UTC
svn commit: r550777 - in /incubator/wicket/trunk/jdk-1.4/wicket/src:
main/java/org/apache/wicket/util/lang/PropertyResolver.java
test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
Author: jcompagner
Date: Tue Jun 26 04:54:45 2007
New Revision: 550777
URL: http://svn.apache.org/viewvc?view=rev&rev=550777
Log:
WICKET-698
now for a list i do try to find a field when the rest is failing:
findMethod if expresion is () or findGetter
if method not found then look if it is an index.
if that fails then it will look for a method anyway and last it will look for the field
For a Map this doesnt happen. You can't have fields in a map you can only target
fields through a getter in a Map or explicitly by defining map.xxx() so it will just look up the method.
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java?view=diff&rev=550777&r1=550776&r2=550777
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java Tue Jun 26 04:54:45 2007
@@ -319,9 +319,17 @@
}
else
{
- throw new WicketRuntimeException("The expression '" + exp
- + "' is neither an index nor is it a method for the list "
- + clz);
+ field = findField(clz, exp);
+ if (field != null)
+ {
+ getAndSetter = new FieldGetAndSetter(field);
+ }
+ else
+ {
+ throw new WicketRuntimeException("The expression '" + exp
+ + "' is neither an index nor is it a method or field for the list "
+ + clz);
+ }
}
}
}
@@ -586,6 +594,7 @@
public Object getValue(final Object object);
/**
+ * @param object
* @return
*/
public Class getTargetClass(final Object object);
Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java?view=diff&rev=550777&r1=550776&r2=550777
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java Tue Jun 26 04:54:45 2007
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Vector;
import junit.framework.TestCase;
@@ -449,5 +450,27 @@
person.setAddressArray(new Address[] { new Address(), new Address() });
method = PropertyResolver.getPropertySetter("addressArray[0].number", person);
assertEquals(method.getName(), "setNumber");
+ }
+
+ /**
+ * Used for models in testing.
+ */
+ private static class InnerVectorPOJO extends Vector
+ {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ public String testValue = "vector";
+ }
+
+ /**
+ * Tests the PropertyModel with vector.
+ */
+ public void testPropertyModel()
+ {
+ String value = (String)PropertyResolver.getValue("testValue", new InnerVectorPOJO());
+ assertEquals("vector", value);
}
}