Revision: 787
          http://stripes.svn.sourceforge.net/stripes/?rev=787&view=rev
Author:   tfenne
Date:     2008-01-21 08:13:48 -0800 (Mon, 21 Jan 2008)

Log Message:
-----------
Fix for STS-483: Refactor DefaultActionBeanPropertyBinder for easier extending

Modified Paths:
--------------
    
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java
===================================================================
--- 
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java
   2008-01-21 15:16:35 UTC (rev 786)
+++ 
trunk/stripes/src/net/sourceforge/stripes/controller/DefaultActionBeanPropertyBinder.java
   2008-01-21 16:13:48 UTC (rev 787)
@@ -63,6 +63,9 @@
         this.configuration = configuration;
     }
 
+    /** Returns the Configuration object that was passed to the init() method. 
*/
+    protected Configuration getConfiguration() { return configuration; }
+
     /**
      * <p>
      * Loops through the parameters contained in the request and attempts to 
bind each one to the
@@ -486,8 +489,7 @@
                     for (Map.Entry<ParameterName, String[]> entry : 
row.entrySet()) {
                         ParameterName name = entry.getKey();
                         String[] values = entry.getValue();
-                        ValidationMetadata validationInfo = 
validationInfos.get(name
-                                .getStrippedName());
+                        ValidationMetadata validationInfo = 
validationInfos.get(name.getStrippedName());
 
                         if (validationInfo != null
                                 && 
validationInfo.requiredOn(bean.getContext().getEventName())) {
@@ -817,30 +819,34 @@
 
         return returns;
     }
-}
 
-class Row extends HashMap<ParameterName, String[]> {
-    private static final long serialVersionUID = 1L;
-
-    private boolean hasNonEmptyValues = false;
-
     /**
-     * Adds the value to the map, along the way checking to see if there are 
any non-null values for
-     * the row so far.
+     * An inner class that represents a "row" of form properties that all have 
the same index
+     * so that we can validate all those properties together. 
      */
-    @Override
-    public String[] put(ParameterName key, String[] values) {
-        if (!hasNonEmptyValues) {
-            hasNonEmptyValues = (values != null) && (values.length > 0) && 
(values[0] != null)
-                    && (values[0].trim().length() > 0);
+    protected static class Row extends HashMap<ParameterName, String[]> {
+        private static final long serialVersionUID = 1L;
 
+        private boolean hasNonEmptyValues = false;
+
+        /**
+         * Adds the value to the map, along the way checking to see if there 
are any non-null values for
+         * the row so far.
+         */
+        @Override
+        public String[] put(ParameterName key, String[] values) {
+            if (!hasNonEmptyValues) {
+                hasNonEmptyValues = (values != null) && (values.length > 0) && 
(values[0] != null)
+                        && (values[0].trim().length() > 0);
+
+            }
+            return super.put(key, values);
         }
-        return super.put(key, values);
-    }
 
-    /** Returns true if the row had any non-empty values in it, otherwise 
false. */
-    public boolean hasNonEmptyValues() {
-        return this.hasNonEmptyValues;
+        /** Returns true if the row had any non-empty values in it, otherwise 
false. */
+        public boolean hasNonEmptyValues() {
+            return this.hasNonEmptyValues;
+        }
     }
 }
 
@@ -887,8 +893,7 @@
             try {
                 result = BeanUtil.getPropertyValue(property, bean);
             }
-            catch (Exception e) {
-            }
+            catch (Exception e) { /* Do nothing, this isn't unexpected. */ }
 
             if (result == null) {
                 result = delegate.resolveVariable(property);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to