Author: ivaynberg
Date: Sat Feb  9 12:15:13 2008
New Revision: 620187

URL: http://svn.apache.org/viewvc?rev=620187&view=rev
Log:
WICKET-1308: introduced overridable FC#shouldTrimInput() to determine whether 
or not fc will trim input prior to processing it

Modified:
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java?rev=620187&r1=620186&r2=620187&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
 Sat Feb  9 12:15:13 2008
@@ -613,7 +613,7 @@
                }
                else
                {
-                       return input[0].trim();
+                       return trim(input[0]);
                }
        }
 
@@ -1211,7 +1211,7 @@
         */
        protected Object convertValue(String[] value) throws ConversionException
        {
-               return value != null && value.length > 0 && value[0] != null ? 
value[0].trim() : null;
+               return value != null && value.length > 0 && value[0] != null ? 
trim(value[0]) : null;
        }
 
        /**
@@ -1366,6 +1366,33 @@
         */
        protected void onValid()
        {
+       }
+
+       /**
+        * Determines whether or not this component should trim its input prior 
to processing it. The
+        * default value is <code>true</code>
+        * 
+        * @return True if the input should be trimmed.
+        */
+       protected boolean shouldTrimInput()
+       {
+               return true;
+       }
+
+       /**
+        * Trims the input according to [EMAIL PROTECTED] #shouldTrimInput()}
+        * 
+        * @param string
+        * @return trimmed input if [EMAIL PROTECTED] #shouldTrimInput()} 
returns true, unchanged input otherwise
+        */
+       protected final String trim(String string)
+       {
+               String trimmed = string;
+               if (trimmed != null && shouldTrimInput())
+               {
+                       trimmed = trimmed.trim();
+               }
+               return trimmed;
        }
 
        /**


Reply via email to