click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From med...@apache.org
Subject svn commit: r1310677 - in /click/trunk/click: ./ build/ framework/src/org/apache/click/service/ framework/src/org/apache/click/util/ framework/test/org/apache/click/pages/ framework/test/org/apache/click/service/ framework/test/org/apache/click/util/
Date Sat, 07 Apr 2012 05:34:45 GMT
Author: medgar
Date: Sat Apr  7 05:34:44 2012
New Revision: 1310677

URL: http://svn.apache.org/viewvc?rev=1310677&view=rev
Log:
CLK-306

Added:
    click/trunk/click/framework/src/org/apache/click/service/MVELPropertyService.java
    click/trunk/click/framework/src/org/apache/click/service/OGNLPropertyService.java
    click/trunk/click/framework/src/org/apache/click/service/OGNLTypeConverter.java
    click/trunk/click/framework/src/org/apache/click/service/PropertyService.java
    click/trunk/click/framework/test/org/apache/click/service/MVELPropertyServiceTest.java
    click/trunk/click/framework/test/org/apache/click/service/OGNLPropertyServiceTest.java
    click/trunk/click/framework/test/org/apache/click/service/PropertyServiceTestCase.java
Modified:
    click/trunk/click/.classpath
    click/trunk/click/build/build.properties
    click/trunk/click/build/build.xml
    click/trunk/click/framework/src/org/apache/click/service/ConfigService.java
    click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
    click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java
    click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java
    click/trunk/click/framework/test/org/apache/click/util/ParentObject.java
    click/trunk/click/framework/test/org/apache/click/util/PropertyUtilsTest.java

Modified: click/trunk/click/.classpath
URL: http://svn.apache.org/viewvc/click/trunk/click/.classpath?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/.classpath (original)
+++ click/trunk/click/.classpath Sat Apr  7 05:34:44 2012
@@ -28,5 +28,6 @@
 	<classpathentry kind="lib" path="lib/velocity-1.7.jar"/>
 	<classpathentry kind="lib" path="lib/servlet-api-2.4.jar"/>
 	<classpathentry kind="lib" path="lib/mvel2-2.0.19.jar"/>
+	<classpathentry kind="lib" path="lib/ognl-2.6.9.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: click/trunk/click/build/build.properties
URL: http://svn.apache.org/viewvc/click/trunk/click/build/build.properties?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/build/build.properties (original)
+++ click/trunk/click/build/build.properties Sat Apr  7 05:34:44 2012
@@ -52,6 +52,7 @@ hibernate.version=3.2.6.ga
 junit.version=3.8.1
 log4j.version=1.2.16
 mvel2.version=2.0.19
+ognl.version=2.6.9
 servlet-api.version=2.4
 spring.version=2.5.6
 velocity.version=1.7

Modified: click/trunk/click/build/build.xml
URL: http://svn.apache.org/viewvc/click/trunk/click/build/build.xml?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/build/build.xml (original)
+++ click/trunk/click/build/build.xml Sat Apr  7 05:34:44 2012
@@ -41,6 +41,7 @@
    <property name="jar.lang" value="commons-lang-${commons-lang.version}.jar"/>
    <property name="jar.log4j" value="log4j-${log4j.version}.jar"/>
    <property name="jar.mvel2" value="mvel2-${mvel2.version}.jar"/>
+   <property name="jar.ognl" value="ognl-${ognl.version}.jar"/>
    <property name="jar.servlet" value="servlet-api-${servlet-api.version}.jar"/>
    <property name="jar.slf4j" value="slf4j-api-${slf4j.version}.jar"/>
    <property name="jar.spring" value="spring-${spring.version}.jar"/>
@@ -110,6 +111,7 @@
       <pathelement location="lib/${jar.io}"/>
       <pathelement location="lib/${jar.lang}"/>
    	  <pathelement location="lib/${jar.mvel2}"/>
+   	  <pathelement location="lib/${jar.ognl}"/>
       <pathelement location="lib/${jar.servlet}"/>
       <pathelement location="lib/${jar.upload}"/>
       <pathelement location="lib/${jar.velocity}"/>
@@ -133,6 +135,7 @@
       <pathelement location="lib/${jar.collections}"/>
       <pathelement location="lib/${jar.io}"/>
       <pathelement location="lib/${jar.lang}"/>
+      <pathelement location="lib/${jar.ognl}"/>
       <pathelement location="lib/${jar.servlet}"/>
       <pathelement location="lib/${jar.upload}"/>
       <pathelement location="lib/${jar.velocity}"/>
@@ -192,6 +195,7 @@
             <exclude name="lib/${jar.log4j}"/>
             <exclude name="lib/${jar.junit}"/>
          	<exclude name="lib/${jar.mvel2}"/>
+         	<exclude name="lib/${jar.ognl}"/>
             <exclude name="lib/${jar.servlet}"/>
             <exclude name="lib/${jar.slf4j}"/>
             <exclude name="lib/${jar.velocity}"/>
@@ -325,6 +329,7 @@
       <unzip src="lib/${jar.io}" dest="temp"/>
       <unzip src="lib/${jar.lang}" dest="temp"/> 
       <unzip src="lib/${jar.mvel2}" dest="temp"/> 
+      <unzip src="lib/${jar.ognl}" dest="temp"/> 
       <unzip src="lib/${jar.upload}" dest="temp"/>
       <unzip src="lib/${jar.velocity}" dest="temp"/> 
       <copy todir="${dir.classes}">
@@ -540,6 +545,7 @@
       <downloadMacro name="${jar.lang}" path="commons-lang/commons-lang/${commons-lang.version}"/>
       <downloadMacro name="${jar.log4j}" path="log4j/log4j/${log4j.version}"/>
    	  <downloadMacro name="${jar.mvel2}" path="org/mvel/mvel2/${mvel2.version}"/>
+   	  <downloadMacro name="${jar.ognl}" path="ognl/ognl/${ognl.version}"/>
       <downloadMacro name="${jar.upload}" path="commons-fileupload/commons-fileupload/${commons-fileupload.version}"/>
       <downloadMacro name="${jar.junit}" path="junit/junit/${junit.version}"/>
       <downloadMacro name="${jar.servlet}" path="javax/servlet/servlet-api/${servlet-api.version}"/>

Modified: click/trunk/click/framework/src/org/apache/click/service/ConfigService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/ConfigService.java?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/ConfigService.java (original)
+++ click/trunk/click/framework/src/org/apache/click/service/ConfigService.java Sat Apr  7 05:34:44 2012
@@ -162,6 +162,13 @@ public interface ConfigService {
     public LogService getLogService();
 
     /**
+     * Return the application property service.
+     *
+     * @return the application property service
+     */
+    public PropertyService getPropertyService();
+
+    /**
      * Return the application resource service.
      *
      * @return the application resource service.

Added: click/trunk/click/framework/src/org/apache/click/service/MVELPropertyService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/MVELPropertyService.java?rev=1310677&view=auto
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/MVELPropertyService.java (added)
+++ click/trunk/click/framework/src/org/apache/click/service/MVELPropertyService.java Sat Apr  7 05:34:44 2012
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.click.service;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.servlet.ServletContext;
+
+import org.apache.click.util.PropertyUtils;
+import org.mvel2.MVEL;
+
+/**
+ * Provides an MVEL based property services.
+ */
+public class MVELPropertyService implements PropertyService {
+
+    /** Provides a synchronized cache of MVEL expressions. */
+    private static final Map<String, Serializable> MVEL_EXPRESSION_CACHE
+        = new ConcurrentHashMap<String, Serializable>();
+
+    // Public Methods --------------------------------------------------------
+
+    /**
+     * @see PropertyService#onInit(ServletContext)
+     *
+     * @param servletContext the application servlet context
+     * @throws IOException if an IO error occurs initializing the service
+     */
+    public void onInit(ServletContext servletContext) throws IOException {
+    }
+
+    /**
+     * @see PropertyService#onDestroy()
+     */
+    public void onDestroy() {
+    }
+
+    /**
+     * @see PropertyService#getValue(Object, String)
+     *
+     * @param source the source object
+     * @param name the name of the property
+     * @return the property value for the given source object and property name
+     */
+    public Object getValue(Object source, String name) {
+        return PropertyUtils.getValue(source, name);
+    }
+
+    /**
+     * @see PropertyService#getValue(Object, String, Map)
+     *
+     * @param source the source object
+     * @param name the name of the property
+     * @param cache the cache of reflected property Method objects, do NOT modify
+     * this cache
+     * @return the property value for the given source object and property name
+     */
+    public Object getValue(Object source, String name, Map<?, ?> cache) {
+        return PropertyUtils.getValue(source, name, cache);
+    }
+
+    /**
+     * @see PropertyService#setValue(Object, String, Object)
+     *
+     * @param target the target object to set the property of
+     * @param name the name of the property to set
+     * @param value the property value to set
+     */
+    public void setValue(Object target, String name, Object value) {
+
+        String expression = target.getClass().getSimpleName() + "." + name + " = value";
+
+        Serializable compiledExpression = MVEL_EXPRESSION_CACHE.get(expression);
+
+        if (compiledExpression == null) {
+            compiledExpression = MVEL.compileExpression(expression);
+            MVEL_EXPRESSION_CACHE.put(expression, compiledExpression);
+        }
+
+        Map<String, Object> vars = new HashMap<String, Object>();
+        vars.put(target.getClass().getSimpleName(), target);
+        vars.put("value", value);
+
+        MVEL.executeExpression(compiledExpression, vars);
+    }
+
+}

Added: click/trunk/click/framework/src/org/apache/click/service/OGNLPropertyService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/OGNLPropertyService.java?rev=1310677&view=auto
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/OGNLPropertyService.java (added)
+++ click/trunk/click/framework/src/org/apache/click/service/OGNLPropertyService.java Sat Apr  7 05:34:44 2012
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.click.service;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.servlet.ServletContext;
+
+import ognl.Ognl;
+import ognl.OgnlException;
+
+import org.apache.click.util.PropertyUtils;
+
+/**
+ * Provides an OGNL based property services.
+ */
+public class OGNLPropertyService implements PropertyService {
+
+    /** Provides a synchronized cache of OGNL expressions. */
+    private static final Map<String, Object> OGNL_EXPRESSION_CACHE
+        = new ConcurrentHashMap<String, Object>();
+
+    //Public Methods  --------------------------------------------------------
+
+    /**
+     * @see PropertyService#onInit(ServletContext)
+     *
+     * @param servletContext the application servlet context
+     * @throws IOException if an IO error occurs initializing the service
+     */
+    public void onInit(ServletContext servletContext) throws IOException {
+    }
+
+    /**
+     * @see PropertyService#onDestroy()
+     */
+    public void onDestroy() {
+    }
+
+    /**
+     * @see PropertyService#getValue(Object, String)
+     *
+     * @param source the source object
+     * @param name the name of the property
+     * @return the property value for the given source object and property name
+     */
+    public Object getValue(Object source, String name) {
+        return PropertyUtils.getValue(source, name);
+    }
+
+    /**
+     * @see PropertyService#getValue(Object, String, Map)
+     *
+     * @param source the source object
+     * @param name the name of the property
+     * @param cache the cache of reflected property Method objects, do NOT modify
+     * this cache
+     * @return the property value for the given source object and property name
+     */
+    public Object getValue(Object source, String name, Map<?, ?> cache) {
+        return PropertyUtils.getValue(source, name);
+    }
+
+    /**
+     * @see PropertyService#setValue(Object, String, Object)
+     *
+     * @param target the target object to set the property of
+     * @param name the name of the property to set
+     * @param value the property value to set
+     */
+    public void setValue(Object target, String name, Object value) {
+        OGNLTypeConverter typeConverter = new OGNLTypeConverter();
+
+        Map<?, ?> ognlContext =
+            Ognl.createDefaultContext(target, null, typeConverter);
+
+        try {
+            Object expression = OGNL_EXPRESSION_CACHE.get(name);
+            if (expression == null) {
+                expression = Ognl.parseExpression(name);
+                OGNL_EXPRESSION_CACHE.put(name, expression);
+            }
+
+            Ognl.setValue(expression, ognlContext, target, value);
+
+
+        } catch (OgnlException oe) {
+            throw new RuntimeException(oe.toString(), oe);
+        }
+    }
+
+}
+

Added: click/trunk/click/framework/src/org/apache/click/service/OGNLTypeConverter.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/OGNLTypeConverter.java?rev=1310677&view=auto
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/OGNLTypeConverter.java (added)
+++ click/trunk/click/framework/src/org/apache/click/service/OGNLTypeConverter.java Sat Apr  7 05:34:44 2012
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.click.service;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Member;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+
+import ognl.OgnlOps;
+import ognl.OgnlRuntime;
+import ognl.TypeConverter;
+
+/**
+ * Provides an OGNL TypeConverter class.
+ * <p/>
+ * This class is adapted from the OGNL <tt>DefaultTypeConverter</tt>, by
+ * Luke Blanshard and Drew Davidson, and provides additional Date conversion
+ * capabilities.
+ */
+public class OGNLTypeConverter implements TypeConverter {
+
+    // Public Methods ---------------------------------------------------------
+
+    /**
+     * Converts the given value to a given type.  The OGNL context, target,
+     * member and name of property being set are given.  This method should be
+     * able to handle conversion in general without any context, target, member
+     * or property name specified.
+     *
+     * @param context OGNL context under which the conversion is being done
+     * @param target target object in which the property is being set
+     * @param member member (Constructor, Method or Field) being set
+     * @param propertyName property name being set
+     * @param value value to be converted
+     * @param toType type to which value is converted
+     * @return Converted value of type toType or TypeConverter.NoConversionPossible
+     *  to indicate that the conversion was not possible.
+     */
+    @SuppressWarnings("rawtypes")
+    public Object convertValue(Map context,
+                               Object target,
+                               Member member,
+                               String propertyName,
+                               Object value,
+                               Class toType) {
+
+        return convertValue(value, toType);
+    }
+
+    // ------------------------------------------------------ Protected Methods
+
+    /**
+     * Return the converted value for the given value object and target type.
+     *
+     * @param value the value object to convert
+     * @param toType the target class type to convert the value to
+     * @return a converted value into the specified type
+     */
+    protected Object convertValue(Object value, Class<?> toType) {
+        Object result = null;
+
+        if (value != null) {
+
+            // If array -> array then convert components of array individually
+            if (value.getClass().isArray() && toType.isArray()) {
+                Class<?> componentType = toType.getComponentType();
+
+                result =
+                    Array.newInstance(componentType, Array.getLength(value));
+
+                for (int i = 0, icount = Array.getLength(value); i < icount; i++) {
+                    Array.set(result,
+                              i,
+                              convertValue(Array.get(value, i),
+                              componentType));
+                }
+
+            } else {
+                if ((toType == Integer.class) || (toType == Integer.TYPE)) {
+                    result = Integer.valueOf((int) OgnlOps.longValue(value));
+
+                } else if ((toType == Double.class) || (toType == Double.TYPE)) {
+                    result = new Double(OgnlOps.doubleValue(value));
+
+                } else if ((toType == Boolean.class) || (toType == Boolean.TYPE)) {
+                    result = Boolean.valueOf(value.toString());
+
+                } else if ((toType == Byte.class) || (toType == Byte.TYPE)) {
+                    result = Byte.valueOf((byte) OgnlOps.longValue(value));
+
+                } else if ((toType == Character.class) || (toType == Character.TYPE)) {
+                    result = Character.valueOf((char) OgnlOps.longValue(value));
+
+                } else if ((toType == Short.class) || (toType == Short.TYPE)) {
+                    result = Short.valueOf((short) OgnlOps.longValue(value));
+
+                } else if ((toType == Long.class) || (toType == Long.TYPE)) {
+                    result = Long.valueOf(OgnlOps.longValue(value));
+
+                } else if ((toType == Float.class) || (toType == Float.TYPE)) {
+                    result = new Float(OgnlOps.doubleValue(value));
+
+                } else if (toType == BigInteger.class) {
+                    result = OgnlOps.bigIntValue(value);
+
+                } else if (toType == BigDecimal.class) {
+                    result = bigDecValue(value);
+
+                } else  if (toType == String.class) {
+                    result = OgnlOps.stringValue(value);
+
+                } else if (toType == java.util.Date.class) {
+                    long time = getTimeFromDateString(value.toString());
+                    if (time > Long.MIN_VALUE) {
+                        result = new java.util.Date(time);
+                    }
+
+                } else if (toType == java.sql.Date.class) {
+                    long time = getTimeFromDateString(value.toString());
+                    if (time > Long.MIN_VALUE) {
+                        result = new java.sql.Date(time);
+                    }
+
+                } else if (toType == java.sql.Time.class) {
+                    long time = getTimeFromDateString(value.toString());
+                    if (time > Long.MIN_VALUE) {
+                        result = new java.sql.Time(time);
+                    }
+
+                } else if (toType == java.sql.Timestamp.class) {
+                    long time = getTimeFromDateString(value.toString());
+                    if (time > Long.MIN_VALUE) {
+                        result = new java.sql.Timestamp(time);
+                    }
+                }
+            }
+
+        } else {
+            if (toType.isPrimitive()) {
+                result = OgnlRuntime.getPrimitiveDefaultValue(toType);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Return the time value in milliseconds of the given date value string,
+     * or Long.MIN_VALUE if the date could not be determined.
+     *
+     * @param value the date value string
+     * @return the time value in milliseconds or Long.MIN_VALUE if not determined
+     */
+    protected long getTimeFromDateString(String value) {
+        Validate.notNull(value, "Null value string");
+
+        value = value.trim();
+
+        if (value.length() == 0) {
+            return Long.MIN_VALUE;
+        }
+
+        if (isTimeValue(value)) {
+            return Long.parseLong(value);
+        }
+
+        java.util.Date date = createDateFromSqlString(value);
+        if (date != null) {
+            return date.getTime();
+        }
+
+        try {
+            DateFormat format = DateFormat.getDateInstance();
+
+            date = format.parse(value);
+
+            return date.getTime();
+
+        } catch (ParseException pe) {
+            return Long.MIN_VALUE;
+        }
+    }
+
+    /**
+     * Return true if the given string value is a long time value.
+     *
+     * @param value the string value to test
+     * @return true if the given string value is a long time value.
+     */
+    protected boolean isTimeValue(String value) {
+        for (int i = 0, size = value.length(); i < size; i++) {
+            char aChar = value.charAt(i);
+            if (i == 0) {
+                if (!Character.isDigit(aChar) && aChar != '-') {
+                    return false;
+                }
+            } else {
+                if (!Character.isDigit(aChar)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Return a new date object from the give SQL format date string, or null
+     * if the value is invalid.
+     *
+     * @param value the SQL format date string
+     * @return a new date object from the give SQL format date string
+     */
+    @SuppressWarnings("deprecation")
+    protected java.util.Date createDateFromSqlString(String value) {
+        if (value.length() != 10) {
+            return null;
+        }
+
+        for (int i = 0, size = value.length(); i < size; i++) {
+            char aChar = value.charAt(i);
+            if (!Character.isDigit(aChar) && aChar != '-') {
+                return null;
+            }
+        }
+
+        int firstDash = value.indexOf('-');
+        int secondDash = value.indexOf('-', firstDash + 1);
+
+        if ((firstDash > 0)
+            & (secondDash > 0)
+            & (secondDash < value.length() - 1)) {
+
+            try {
+                int year = Integer.parseInt(value.substring(0, firstDash)) - 1900;
+
+                int month = Integer.parseInt(value.substring(firstDash + 1, secondDash)) - 1;
+
+                int day = Integer.parseInt(value.substring(secondDash + 1));
+
+                return new java.util.Date(year, month, day);
+
+            } catch (NumberFormatException nfe) {
+                return null;
+            }
+
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Convert the given value into a BigDecimal.
+     *
+     * @param value the object to convert into a BigDecimal
+     * @return the converted BigDecimal value
+     */
+    private BigDecimal bigDecValue(Object value) {
+        if (value == null) {
+            return BigDecimal.valueOf(0L);
+        }
+        Class<?> c = value.getClass();
+        if (c == BigDecimal.class) {
+            return (BigDecimal) value;
+        }
+        if (c == BigInteger.class) {
+            return new BigDecimal((BigInteger) value);
+        }
+
+        if (c == Boolean.class) {
+            return BigDecimal.valueOf(((Boolean) value).booleanValue() ? 1 : 0);
+        }
+        if (c == Character.class) {
+            return BigDecimal.valueOf(((Character) value).charValue());
+        }
+
+        return new BigDecimal(value.toString().trim());
+    }
+}

Added: click/trunk/click/framework/src/org/apache/click/service/PropertyService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/PropertyService.java?rev=1310677&view=auto
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/PropertyService.java (added)
+++ click/trunk/click/framework/src/org/apache/click/service/PropertyService.java Sat Apr  7 05:34:44 2012
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.click.service;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Provide a property service with property get and set utility methods.
+ */
+public interface PropertyService {
+
+    /**
+     * Initialize the PropertyService with the given application configuration
+     * service instance.
+     * <p/>
+     * This method is invoked after the PropertyService has been constructed.
+     *
+     * @param servletContext the application servlet context
+     * @throws IOException if an IO error occurs initializing the service
+     */
+    public void onInit(ServletContext servletContext) throws IOException;
+
+    /**
+     * Destroy the PropertyService.
+     */
+    public void onDestroy();
+
+    /**
+     * Return the property value for the given object and property name. This
+     * method uses reflection internally to get the property value.
+     * <p/>
+     * This method is thread-safe, and caches reflected accessor methods in an
+     * internal synchronized cache.
+     * <p/>
+     * If the given source object is a <tt>Map</tt> this method will simply
+     * return the value for the given key name.
+     *
+     * @param source the source object
+     * @param name the name of the property
+     * @return the property value for the given source object and property name
+     */
+    public Object getValue(Object source, String name);
+
+    /**
+     * Return the property value for the given object and property name. This
+     * method uses reflection internally to get the property value.
+     * <p/>
+     * This method caches the reflected property methods in the given Map cache.
+     * You must NOT modify the cache. Also note cache is ONLY valid for the
+     * current thread, as access to the cache is not synchronized. If you need
+     * multi-threaded access to shared cache use a thread-safe Map object, such
+     * as <tt>Collections.synchronizedMap(new HashMap())</tt>.
+     * <p/>
+     * If the given source object is a <tt>Map</tt> this method will simply
+     * return the value for the given key name.
+     *
+     * @param source the source object
+     * @param name the name of the property
+     * @param cache the cache of reflected property Method objects, do NOT modify
+     * this cache
+     * @return the property value for the given source object and property name
+     */
+    public Object getValue(Object source, String name, Map<?, ?> cache);
+
+    /**
+     * Return the property value for the given object and property name using the MVEL library.
+     *
+     * @param target the target object to set the property of
+     * @param name the name of the property to set
+     * @param value the property value to set
+     */
+    public void setValue(Object target, String name, Object value);
+
+}

Modified: click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java (original)
+++ click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java Sat Apr  7 05:34:44 2012
@@ -191,6 +191,9 @@ public class XmlConfigService implements
     /** The ServletContext instance. */
     private ServletContext servletContext;
 
+    /** The application PropertyService. */
+    private PropertyService propertyService;
+
     /** The application ResourceService. */
     private ResourceService resourceService;
 
@@ -265,6 +268,9 @@ public class XmlConfigService implements
             // Load the locale
             loadLocale(rootElm);
 
+            // Load the Property service
+            loadPropertyService(rootElm);
+
             // Load the File Upload service
             loadFileUploadService(rootElm);
 
@@ -292,6 +298,9 @@ public class XmlConfigService implements
         if (getFileUploadService() != null) {
             getFileUploadService().onDestroy();
         }
+        if (getPropertyService() != null) {
+            getPropertyService().onDestroy();
+        }
         if (getTemplateService() != null) {
             getTemplateService().onDestroy();
         }
@@ -346,6 +355,16 @@ public class XmlConfigService implements
     }
 
     /**
+     * @see ConfigService#getProperyService()
+     *
+     * @return the application property service.
+     */
+    public PropertyService getPropertyService() {
+        // TODO
+        return new OGNLPropertyService();
+    }
+
+    /**
      * @see ConfigService#getResourceService()
      *
      * @return the resource service
@@ -640,8 +659,9 @@ public class XmlConfigService implements
      *
      * @return the list of configured page classes
      */
-    public List getPageClassList() {
-        List classList = new ArrayList(pageByClassMap.size());
+    public List<Class<? extends Page>> getPageClassList() {
+        List<Class<? extends Page>> classList =
+            new ArrayList<Class<? extends Page>>(pageByClassMap.size());
 
         Iterator i = pageByClassMap.keySet().iterator();
         while (i.hasNext()) {
@@ -854,7 +874,7 @@ public class XmlConfigService implements
         String path = pagePath.substring(0, pagePath.lastIndexOf("."));
 
         // If page is excluded return the excluded class
-        Class excludePageClass = getExcludesPageClass(path);
+        Class<? extends  Page> excludePageClass = getExcludesPageClass(path);
         if (excludePageClass != null) {
             return excludePageClass;
         }
@@ -972,7 +992,7 @@ public class XmlConfigService implements
      * not be found on the classpath
      */
     void loadPages(Element rootElm) throws ClassNotFoundException {
-        List pagesList = ClickUtils.getChildren(rootElm, "pages");
+        List<Element> pagesList = ClickUtils.getChildren(rootElm, "pages");
 
         if (pagesList.isEmpty()) {
             String msg = "required configuration 'pages' element missing.";
@@ -981,9 +1001,7 @@ public class XmlConfigService implements
 
         List templates = getTemplateFiles();
 
-        for (int i = 0; i < pagesList.size(); i++) {
-
-            Element pagesElm = (Element) pagesList.get(i);
+        for (Element pagesElm : pagesList) {
 
             // Determine whether to use automapping
             boolean automap = true;
@@ -1194,13 +1212,10 @@ public class XmlConfigService implements
      * @param parentElm the element to load the headers from
      * @return the map of Page headers
      */
-    static Map loadHeadersMap(Element parentElm) {
-        Map headersMap = new HashMap();
-
-        List headerList = ClickUtils.getChildren(parentElm, "header");
+    static Map<String, Object> loadHeadersMap(Element parentElm) {
+        Map<String, Object> headersMap = new HashMap<String, Object>();
 
-        for (int i = 0, size = headerList.size(); i < size; i++) {
-            Element header = (Element) headerList.get(i);
+        for (Element header : ClickUtils.getChildren(parentElm, "header")) {
 
             String name = header.getAttribute("name");
             String type = header.getAttribute("type");
@@ -1264,10 +1279,7 @@ public class XmlConfigService implements
             return;
         }
 
-        List deployableList = ClickUtils.getChildren(controlsElm, "control");
-
-        for (int i = 0; i < deployableList.size(); i++) {
-            Element deployableElm = (Element) deployableList.get(i);
+        for (Element deployableElm : ClickUtils.getChildren(controlsElm, "control")) {
 
             String classname = deployableElm.getAttribute("classname");
             if (StringUtils.isBlank(classname)) {
@@ -1294,10 +1306,8 @@ public class XmlConfigService implements
             return;
         }
 
-        List controlSets = ClickUtils.getChildren(controlsElm, "control-set");
+        for (Element controlSet : ClickUtils.getChildren(controlsElm, "control-set")) {
 
-        for (int i = 0; i < controlSets.size(); i++) {
-            Element controlSet = (Element) controlSets.get(i);
             String name = controlSet.getAttribute("name");
             if (StringUtils.isBlank(name)) {
                 String msg =
@@ -1535,13 +1545,12 @@ public class XmlConfigService implements
 
             fileUploadService = (FileUploadService) fileUploadServiceClass.newInstance();
 
-            Map propertyMap = loadPropertyMap(fileUploadServiceElm);
+            Map<String, String> propertyMap = loadPropertyMap(fileUploadServiceElm);
 
-            for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();) {
-                String name = i.next().toString();
+            for (String name : propertyMap.keySet()) {
                 String value = propertyMap.get(name).toString();
 
-                PropertyUtils.setValue(fileUploadService, name, value);
+                getPropertyService().setValue(fileUploadService, name, value);
             }
 
         } else {
@@ -1571,13 +1580,12 @@ public class XmlConfigService implements
 
             logService = (LogService) logServiceClass.newInstance();
 
-            Map propertyMap = loadPropertyMap(logServiceElm);
+            Map<String, String> propertyMap = loadPropertyMap(logServiceElm);
 
-            for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();) {
-                String name = i.next().toString();
+            for (String name : propertyMap.keySet()) {
                 String value = propertyMap.get(name).toString();
 
-                PropertyUtils.setValue(logService, name, value);
+                getPropertyService().setValue(logService, name, value);
             }
         } else {
             logService = new ConsoleLogService();
@@ -1600,13 +1608,12 @@ public class XmlConfigService implements
 
             messagesMapService = (MessagesMapService) messagesMapServiceClass.newInstance();
 
-            Map propertyMap = loadPropertyMap(messagesMapServiceElm);
+            Map<String, String> propertyMap = loadPropertyMap(messagesMapServiceElm);
 
-            for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();) {
-                String name = i.next().toString();
+            for (String name : propertyMap.keySet()) {
                 String value = propertyMap.get(name).toString();
 
-                PropertyUtils.setValue(messagesMapService, name, value);
+                getPropertyService().setValue(messagesMapService, name, value);
             }
         }
 
@@ -1631,11 +1638,10 @@ public class XmlConfigService implements
 
             Class interceptorClass = ClickUtils.classForName(classname);
 
-            Map propertyMap = loadPropertyMap(interceptorElm);
+            Map<String, String> propertyMap = loadPropertyMap(interceptorElm);
             List<Property> propertyList = new ArrayList<Property>();
 
-            for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();) {
-                String name = i.next().toString();
+            for (String name : propertyMap.keySet()) {
                 String value = propertyMap.get(name).toString();
 
                 propertyList.add(new Property(name, value));
@@ -1663,13 +1669,12 @@ public class XmlConfigService implements
 
             resourceService = (ResourceService) resourceServiceClass.newInstance();
 
-            Map propertyMap = loadPropertyMap(resourceServiceElm);
+            Map<String, String> propertyMap = loadPropertyMap(resourceServiceElm);
 
-            for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();) {
-                String name = i.next().toString();
+            for (String name : propertyMap.keySet()) {
                 String value = propertyMap.get(name).toString();
 
-                PropertyUtils.setValue(resourceService, name, value);
+                getPropertyService().setValue(resourceService, name, value);
             }
 
         } else {
@@ -1685,6 +1690,33 @@ public class XmlConfigService implements
         resourceService.onInit(servletContext);
     }
 
+    private void loadPropertyService(Element rootElm) throws Exception {
+        Element propertyServiceElm = ClickUtils.getChild(rootElm, "property-service");
+
+        if (propertyServiceElm != null) {
+            Class propertyServiceClass = OGNLPropertyService.class;
+
+            String classname = propertyServiceElm.getAttribute("classname");
+
+            if (StringUtils.isNotBlank(classname)) {
+                propertyServiceClass = ClickUtils.classForName(classname);
+            }
+
+            propertyService = (PropertyService) propertyServiceClass.newInstance();
+
+        } else {
+            propertyService = new OGNLPropertyService();
+        }
+
+        if (getLogService().isDebugEnabled()) {
+            String msg = "initializing PropertyService: "
+                + propertyService.getClass().getName();
+            getLogService().debug(msg);
+        }
+
+        propertyService.onInit(servletContext);
+    }
+
     private void loadTemplateService(Element rootElm) throws Exception {
         Element templateServiceElm = ClickUtils.getChild(rootElm, "template-service");
 
@@ -1699,13 +1731,12 @@ public class XmlConfigService implements
 
             templateService = (TemplateService) templateServiceClass.newInstance();
 
-            Map propertyMap = loadPropertyMap(templateServiceElm);
+            Map<String, String> propertyMap = loadPropertyMap(templateServiceElm);
 
-            for (Iterator i = propertyMap.keySet().iterator(); i.hasNext();) {
-                String name = i.next().toString();
+            for (String name : propertyMap.keySet()) {
                 String value = propertyMap.get(name).toString();
 
-                PropertyUtils.setValue(templateService, name, value);
+                getPropertyService().setValue(templateService, name, value);
             }
 
         } else {
@@ -1721,14 +1752,10 @@ public class XmlConfigService implements
         templateService.onInit(servletContext);
     }
 
-    private static Map loadPropertyMap(Element parentElm) {
-        Map propertyMap = new HashMap();
-
-        List propertyList = ClickUtils.getChildren(parentElm, "property");
-
-        for (int i = 0, size = propertyList.size(); i < size; i++) {
-            Element property = (Element) propertyList.get(i);
+    private static Map<String, String> loadPropertyMap(Element parentElm) {
+        Map<String, String> propertyMap = new HashMap<String, String>();
 
+        for (Element property : ClickUtils.getChildren(parentElm, "property")) {
             String name = property.getAttribute("name");
             String value = property.getAttribute("value");
 

Modified: click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java (original)
+++ click/trunk/click/framework/src/org/apache/click/util/PropertyUtils.java Sat Apr  7 05:34:44 2012
@@ -18,28 +18,27 @@
  */
 package org.apache.click.util;
 
-import java.io.Serializable;
 import java.lang.reflect.Method;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.mvel2.MVEL;
+import javax.servlet.ServletContext;
+
+import org.apache.click.Context;
+import org.apache.click.service.ConfigService;
+import org.apache.click.service.PropertyService;
+
 
 /**
- * Provide property getter and setter utility methods.
+ * Provide property getter and setter utility methods. This class is provided
+ * for backward compatibility.
  */
-@SuppressWarnings("unchecked")
 public class PropertyUtils {
 
     /** Provides a synchronized cache of get value reflection methods. */
     private static final Map<String, Object> GET_METHOD_CACHE
         = new ConcurrentHashMap<String, Object>();
 
-    /** Provides a synchronized cache of MVEL expressions. */
-    private static final Map<String, Serializable> MVEL_EXPRESSION_CACHE
-        = new ConcurrentHashMap<String, Serializable>();
-
     // -------------------------------------------------------- Public Methods
 
     /**
@@ -131,24 +130,10 @@ public class PropertyUtils {
      * @param value the property value to set
      */
     public static void setValue(Object target, String name, Object value) {
-
-        String expression = target.getClass().getSimpleName() + "." + name + " = value";
-
-        Serializable compiledExpression = MVEL_EXPRESSION_CACHE.get(expression);
-
-        if (compiledExpression == null) {
-            compiledExpression = MVEL.compileExpression(expression);
-            MVEL_EXPRESSION_CACHE.put(expression, compiledExpression);
-        }
-
-        Map vars = new HashMap();
-        vars.put(target.getClass().getSimpleName(), target);
-        vars.put("value", value);
-
-        MVEL.executeExpression(compiledExpression, vars);
+        getPropertyService().setValue(target, name, value);
     }
 
-    // -------------------------------------------------------- Private Methods
+    // Private Methods --------------------------------------------------------
 
     /**
      * Return the property value for the given object and property name. This
@@ -160,7 +145,7 @@ public class PropertyUtils {
      * @return the property value for the given source object and property name
      */
     private static Object getObjectPropertyValue(Object source, String name, Map cache) {
-        PropertyUtils.CacheKey methodNameKey = new PropertyUtils.CacheKey(source, name);
+        CacheKey methodNameKey = new CacheKey(source, name);
 
         Method method = null;
         try {
@@ -212,14 +197,23 @@ public class PropertyUtils {
         }
     }
 
-    // ---------------------------------------------------------- Inner Classes
+    private static PropertyService getPropertyService() {
+        ServletContext servletContext =
+            Context.getThreadLocalContext().getServletContext();
+
+        ConfigService configService = ClickUtils.getConfigService(servletContext);
+
+        return configService.getPropertyService();
+    }
+
+    // Inner Classes ----------------------------------------------------------
 
     /**
      * See DRY Performance article by Kirk Pepperdine.
      * <p/>
      * http://www.javaspecialists.eu/archive/Issue134.html
      */
-    private static class CacheKey {
+    public static class CacheKey {
 
         /** Class to encapsulate in cache key. */
         private final Class sourceClass;

Modified: click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java (original)
+++ click/trunk/click/framework/test/org/apache/click/pages/RequestBindingPage.java Sat Apr  7 05:34:44 2012
@@ -29,9 +29,9 @@ import org.apache.click.util.Bindable;
 public class RequestBindingPage extends Page {
     private static final long serialVersionUID = 1L;
 
-    @Bindable private BigDecimal bigDecimal = BigDecimal.ZERO;
+    @Bindable public BigDecimal bigDecimal = BigDecimal.ZERO;
     public String string = "";
-    @Bindable private boolean bool = false;
+    @Bindable public boolean bool = false;
 
     public RequestBindingPage() {
     }

Added: click/trunk/click/framework/test/org/apache/click/service/MVELPropertyServiceTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/service/MVELPropertyServiceTest.java?rev=1310677&view=auto
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/service/MVELPropertyServiceTest.java (added)
+++ click/trunk/click/framework/test/org/apache/click/service/MVELPropertyServiceTest.java Sat Apr  7 05:34:44 2012
@@ -0,0 +1,28 @@
+package org.apache.click.service;
+
+import org.apache.click.servlet.MockServletContext;
+
+
+public class MVELPropertyServiceTest extends PropertyServiceTestCase {
+	
+	@Override
+	protected void setUp() {
+		propertyService = new MVELPropertyService();
+
+		try {
+			propertyService.onInit(new MockServletContext());
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+	
+	@Override
+	protected void tearDown() {
+		try {
+			propertyService.onDestroy();
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+	
+}

Added: click/trunk/click/framework/test/org/apache/click/service/OGNLPropertyServiceTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/service/OGNLPropertyServiceTest.java?rev=1310677&view=auto
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/service/OGNLPropertyServiceTest.java (added)
+++ click/trunk/click/framework/test/org/apache/click/service/OGNLPropertyServiceTest.java Sat Apr  7 05:34:44 2012
@@ -0,0 +1,28 @@
+package org.apache.click.service;
+
+import org.apache.click.servlet.MockServletContext;
+
+
+public class OGNLPropertyServiceTest extends PropertyServiceTestCase {
+	
+	@Override
+	protected void setUp() {
+		propertyService = new OGNLPropertyService();
+
+		try {
+			propertyService.onInit(new MockServletContext());
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+	
+	@Override
+	protected void tearDown() {
+		try {
+			propertyService.onDestroy();
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+	
+}

Added: click/trunk/click/framework/test/org/apache/click/service/PropertyServiceTestCase.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/service/PropertyServiceTestCase.java?rev=1310677&view=auto
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/service/PropertyServiceTestCase.java (added)
+++ click/trunk/click/framework/test/org/apache/click/service/PropertyServiceTestCase.java Sat Apr  7 05:34:44 2012
@@ -0,0 +1,96 @@
+package org.apache.click.service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.click.util.ChildObject;
+import org.apache.click.util.ParentObject;
+
+public abstract class PropertyServiceTestCase extends TestCase {
+	
+	protected PropertyService propertyService = null;
+
+    public void test_getValue() {
+    	
+        try {
+        	propertyService.getValue(new Object(), "username", new HashMap<Object, Object>());
+            assertTrue(false);
+        } catch (Exception e) {
+            assertTrue(true);
+        }
+
+        try {
+        	propertyService.getValue(new Object(), "class", new HashMap<Object, Object>());
+            assertTrue(true);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        ParentObject testObject = new ParentObject();
+        Map<?, ?> cache = new HashMap<Object, Object>();
+
+        assertNull(propertyService.getValue(testObject, "name", cache));
+        assertNull(propertyService.getValue(testObject, "value", cache));
+        assertNull(propertyService.getValue(testObject, "date", cache));
+        assertNull(propertyService.getValue(testObject, "child", cache));
+
+        assertNull(propertyService.getValue(testObject, "name"));
+        assertNull(propertyService.getValue(testObject, "value"));
+        assertNull(propertyService.getValue(testObject, "date"));
+        assertNull(propertyService.getValue(testObject, "child"));
+
+        ParentObject parentObject =
+            new ParentObject("malcolm", null, new Date(), Boolean.TRUE,
+            new ChildObject("edgar", "medgar@avoka.com"));
+
+        assertEquals("malcolm", propertyService.getValue(parentObject, "name", cache));
+        assertNull(propertyService.getValue(parentObject, "value", cache));
+        assertNotNull(propertyService.getValue(parentObject, "date", cache));
+        assertNotNull(propertyService.getValue(parentObject, "valid", cache));
+        assertEquals("edgar", propertyService.getValue(parentObject, "child.name", cache));
+        assertEquals("medgar@avoka.com", propertyService.getValue(parentObject, "child.email", cache));
+
+
+        assertEquals("malcolm", propertyService.getValue(parentObject, "name"));
+        assertNull(propertyService.getValue(parentObject, "value"));
+        assertNotNull(propertyService.getValue(parentObject, "date"));
+        assertNotNull(propertyService.getValue(parentObject, "valid"));
+        assertEquals("edgar", propertyService.getValue(parentObject, "child.name"));
+        assertEquals("medgar@avoka.com", propertyService.getValue(parentObject, "child.email"));
+        
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("name", "malcolm");
+
+        assertEquals("malcolm", propertyService.getValue(map, "name"));
+    }
+
+    public void test_setValue() {
+    	ParentObject parentObject = new ParentObject();
+
+    	propertyService.setValue(parentObject, "name", "malcolm");
+    	assertEquals("malcolm", parentObject.getName());
+    	
+    	propertyService.setValue(parentObject, "value", "value");
+    	assertEquals("value", parentObject.getValue());
+    	
+    	Date date = new Date();
+    	propertyService.setValue(parentObject, "date", date);
+    	assertEquals(date, parentObject.getDate());
+    	
+    	propertyService.setValue(parentObject, "valid", true);
+    	assertEquals(Boolean.TRUE, parentObject.getValid());
+    	
+        Map<String, Object> map = new HashMap<String, Object>();
+        propertyService.setValue(map, "name", "malcolm");
+    	assertEquals("malcolm", map.get("name"));
+    	
+    	parentObject.setChild(new ChildObject());
+    	
+        propertyService.setValue(parentObject, "child.name", "malcolm");
+        assertEquals("malcolm", parentObject.getChild().getName());
+    }
+
+}

Modified: click/trunk/click/framework/test/org/apache/click/util/ParentObject.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/util/ParentObject.java?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/util/ParentObject.java (original)
+++ click/trunk/click/framework/test/org/apache/click/util/ParentObject.java Sat Apr  7 05:34:44 2012
@@ -39,17 +39,37 @@ public class ParentObject {
     public ParentObject() {
     }
     
-    public String getName() {
-        return name;
-    }
-    
-    public Date getDate() {
-    	return date;
-    }
+    public void setName(String name) {
+		this.name = name;
+	}
     
-    public Object getValue() {
-        return value;
+    public String getName() {
+    	return name;
     }
+
+	public void setValue(Object value) {
+		this.value = value;
+	}
+
+	public Date getDate() {
+		return date;
+	}
+	
+	public void setDate(Date date) {
+		this.date = date;
+	}
+	
+	public Boolean getValid() {
+		return valid;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	public void setValid(Boolean valid) {
+		this.valid = valid;
+	}
     
     public ChildObject getChild() {
     	return child;
@@ -58,9 +78,5 @@ public class ParentObject {
     public void setChild(ChildObject child) {
     	this.child = child;
     }
-    
-    public Boolean getValid() {
-    	return valid;
-    }
 }
 

Modified: click/trunk/click/framework/test/org/apache/click/util/PropertyUtilsTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/util/PropertyUtilsTest.java?rev=1310677&r1=1310676&r2=1310677&view=diff
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/util/PropertyUtilsTest.java (original)
+++ click/trunk/click/framework/test/org/apache/click/util/PropertyUtilsTest.java Sat Apr  7 05:34:44 2012
@@ -93,4 +93,5 @@ public class PropertyUtilsTest extends T
 
         assertEquals("malcolm", PropertyUtils.getValue(map, "name"));
     }
+    
 }



Mime
View raw message