Commits

Anonymous committed da23bc9

WW-2924 Set result parameters one at a time. Add missing setProperty(...) method to reflection provider

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1887e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 9d51abb

Comments (0)

Files changed (3)

File src/java/com/opensymphony/xwork2/ObjectFactory.java

 
         if (resultClassName != null) {
             result = (Result) buildBean(resultClassName, extraContext);
-            try {
-                reflectionProvider.setProperties(resultConfig.getParams(), result, extraContext, true);
-            } catch (ReflectionException ex) {
-                if (result instanceof ReflectionExceptionHandler) {
-                    ((ReflectionExceptionHandler)result).handle(ex);
+            Map<String, String> params = resultConfig.getParams();
+            if (params != null) {
+                for (Map.Entry<String, String> paramEntry : params.entrySet()) {
+                    try {
+                        reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), result, extraContext, true);
+                    } catch (ReflectionException ex) {
+                        if (LOG.isErrorEnabled())
+                            LOG.error("Unable to set parameter [#0] in result of type [#1]", ex,
+                                    paramEntry.getKey(), resultConfig.getClassName());
+                        if (result instanceof ReflectionExceptionHandler) {
+                            ((ReflectionExceptionHandler) result).handle(ex);
+                        }
+                    }
                 }
             }
         }

File src/java/com/opensymphony/xwork2/ognl/OgnlReflectionProvider.java

         ognlUtil.setProperty(name, value, o, context);
     }
 
+    public void setProperty(String name, Object value, Object o, Map<String, Object> context, boolean throwPropertyExceptions) {
+        ognlUtil.setProperty(name, value, o, context, throwPropertyExceptions);
+    }
+
     public Map getBeanMap(Object source) throws IntrospectionException,
             ReflectionException {
         try {

File src/java/com/opensymphony/xwork2/util/reflection/ReflectionProvider.java

     Object getRealTarget(String property, Map<String, Object> context, Object root) throws ReflectionException;
     
     /**
+     * Sets the named property to the supplied value on the Object,
+     *
+     * @param name    the name of the property to be set
+     * @param value   the value to set into the named property
+     * @param o       the object upon which to set the property
+     * @param context the context which may include the TypeConverter
+     * @param throwPropertyExceptions boolean which tells whether it should throw exceptions for
+     *                                problems setting the properties
+     */
+    void setProperty(String name, Object value, Object o, Map<String, Object> context, boolean throwPropertyExceptions);
+
+    /**
      * Sets the named property to the supplied value on the Object, defaults to not throwing
      * property exceptions.
      *