Title: [waffle-scm] [411] trunk/waffle-distribution/src/site/content: Made OgnlValueConverterFinder always default to OgnlValueConverter if no other converters are defined.
Revision
411
Author
mauro
Date
2007-11-22 08:43:18 -0600 (Thu, 22 Nov 2007)

Log Message

Made OgnlValueConverterFinder always default to OgnlValueConverter if no other converters are defined.

Modified Paths

Diff

Modified: trunk/examples/paranamer-example/src/main/webapp/WEB-INF/web.xml (410 => 411)

--- trunk/examples/paranamer-example/src/main/webapp/WEB-INF/web.xml	2007-11-22 14:01:54 UTC (rev 410)
+++ trunk/examples/paranamer-example/src/main/webapp/WEB-INF/web.xml	2007-11-22 14:43:18 UTC (rev 411)
@@ -18,10 +18,6 @@
     </context-param>
     <!-- 2. We are adding a Custom components objects -->
     <context-param>
-        <param-name>register:OgnlConverter</param-name>
-        <param-value>org.codehaus.waffle.bind.OgnlValueConverter</param-value>
-    </context-param>
-    <context-param>
         <param-name>register:DateConverter</param-name>
         <param-value>org.codehaus.waffle.example.paranamer.DateValueConverter</param-value>
     </context-param>

Modified: trunk/examples/simple-example/src/main/webapp/WEB-INF/web.xml (410 => 411)

--- trunk/examples/simple-example/src/main/webapp/WEB-INF/web.xml	2007-11-22 14:01:54 UTC (rev 410)
+++ trunk/examples/simple-example/src/main/webapp/WEB-INF/web.xml	2007-11-22 14:43:18 UTC (rev 411)
@@ -14,10 +14,6 @@
     </context-param>
     <!-- 2. We are adding a custom components -->
     <context-param>
-        <param-name>register:OgnlConverter</param-name>
-        <param-value>org.codehaus.waffle.bind.OgnlValueConverter</param-value>
-    </context-param>
-    <context-param>
         <param-name>register:DateConverter</param-name>
         <param-value>org.codehaus.waffle.example.simple.DateValueConverter</param-value>
     </context-param>

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/ognl/OgnlValueConverterFinder.java (410 => 411)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/ognl/OgnlValueConverterFinder.java	2007-11-22 14:01:54 UTC (rev 410)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/ognl/OgnlValueConverterFinder.java	2007-11-22 14:43:18 UTC (rev 411)
@@ -10,7 +10,11 @@
  *****************************************************************************/
 package org.codehaus.waffle.bind.ognl;
 
+import static java.util.Arrays.asList;
+
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.codehaus.waffle.bind.ValueConverter;
@@ -18,12 +22,9 @@
 
 /**
  * <p>
- * Default implementation of <code>ValueConverterFinder</code> which caches
- * converters found per type.
+ * Implementation of <code>ValueConverterFinder</code> which caches converters 
+ * found per type and uses <code>OgnlValueConverter</code> as default converter.
  * </p>
- * <p>
- * If no converters are specified, the <code>OgnlValueConverter</code> is used as default.
- * </p>
  *
  * @author Michael Ward
  * @author Mauro Talevi
@@ -31,19 +32,22 @@
  */
 public class OgnlValueConverterFinder implements ValueConverterFinder {
 
-    private static final ValueConverter DEFAULT_VALUE_CONVERTER = new OgnlValueConverter();
+    private static final ValueConverter OGNL_VALUE_CONVERTER = new OgnlValueConverter();
+    private final List<ValueConverter> DEFAULT_CONVERTERS = asList(OGNL_VALUE_CONVERTER);
     private final Map<Class<?>, ValueConverter> cache = new HashMap<Class<?>, ValueConverter>();
-    private final ValueConverter[] converters;
+    private final List<ValueConverter> converters;
 
     public OgnlValueConverterFinder() {
-        this.converters = new ValueConverter[]{DEFAULT_VALUE_CONVERTER};
+        this.converters = DEFAULT_CONVERTERS;
     }
 
     public OgnlValueConverterFinder(ValueConverter... converters) {
-        if (converters == null) {
-            this.converters = new ValueConverter[]{DEFAULT_VALUE_CONVERTER};
+        if (converters != null) {
+            this.converters = new ArrayList<ValueConverter>();
+            this.converters.addAll(asList(converters));
+            this.converters.addAll(DEFAULT_CONVERTERS);
         } else {
-            this.converters = converters;
+            this.converters = DEFAULT_CONVERTERS;            
         }
     }
 

Modified: trunk/waffle-distribution/src/site/content/binding-validation.html (410 => 411)

--- trunk/waffle-distribution/src/site/content/binding-validation.html	2007-11-22 14:01:54 UTC (rev 410)
+++ trunk/waffle-distribution/src/site/content/binding-validation.html	2007-11-22 14:43:18 UTC (rev 411)
@@ -18,12 +18,6 @@
     </p>
 
     <p>
-      <b>Note</b>:  If any custom converters are configured, the user needs to configure <b>all</b> converters,
-      including <i>OgnlValueConverter</i> if so desired.  Waffle does not hardcode any converters, it simply 
-      tries to make the default behaviour the most useful to the user.
-    </p>
-    
-    <p>
       A common binding problem that many web application need to deal with is how to bind a String value to a Date
       object. Of course each application and locale has it's own unique format. As an example we will build a class that
       supports binding to a Date. From this example you'll gain an understanding of how to bind to any Class type.


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to