Author: hlship
Date: Tue Aug  5 17:15:10 2008
New Revision: 683056

URL: http://svn.apache.org/viewvc?rev=683056&view=rev
Log:
TAPESTRY-1588: Validation error images are included in the markup for fields 
without errors, even when the form has client validation disabled

Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportAdapter.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportImpl.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/DefaultValidationDecorator.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FormSupport.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages.properties
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_de_DE.properties
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_it.properties
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_pt_PT.properties
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_zh_CN.properties

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportAdapter.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportAdapter.java?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportAdapter.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportAdapter.java
 Tue Aug  5 17:15:10 2008
@@ -65,4 +65,9 @@
     {
         return delegate.getClientId();
     }
+
+    public boolean isClientValidationEnabled()
+    {
+        return delegate.isClientValidationEnabled();
+    }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportImpl.java?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/internal/FormSupportImpl.java
 Tue Aug  5 17:15:10 2008
@@ -141,5 +141,8 @@
             clientBehaviorSupport.addValidation(field, validationName, 
message, constraint);
     }
 
-
+    public boolean isClientValidationEnabled()
+    {
+        return clientValidationEnabled;
+    }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/DefaultValidationDecorator.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/DefaultValidationDecorator.java?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/DefaultValidationDecorator.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/DefaultValidationDecorator.java
 Tue Aug  5 17:15:10 2008
@@ -18,6 +18,7 @@
 import org.apache.tapestry5.dom.Element;
 import org.apache.tapestry5.ioc.Messages;
 import org.apache.tapestry5.services.Environment;
+import org.apache.tapestry5.services.FormSupport;
 
 /**
  * Default implementation that writes an attribute into fields or labels that 
are in error.
@@ -65,20 +66,28 @@
     @Override
     public void afterField(Field field)
     {
-        String iconId = field.getClientId() + ":icon";
+        boolean inError = inError(field);
 
-        String cssClass = inError(field) ? "t-error-icon" : "t-error-icon 
t-invisible";
+        boolean clientValidationEnabled = 
environment.peekRequired(FormSupport.class).isClientValidationEnabled();
 
-        markupWriter.element("img",
+        if (inError || clientValidationEnabled)
+        {
+            String iconId = field.getClientId() + ":icon";
 
-                             "src", iconAsset.toClientURL(),
+            String cssClass = inError ? "t-error-icon" : "t-error-icon 
t-invisible";
 
-                             "alt", validationMessages.get("icon-label"),
+            markupWriter.element("img",
 
-                             "class", cssClass,
+                                 "src", iconAsset.toClientURL(),
+
+                                 "alt", "",
+
+                                 "class", cssClass,
+
+                                 "id", iconId);
+            markupWriter.end();
+        }
 
-                             "id", iconId);
-        markupWriter.end();
     }
 
     private boolean inError(Field field)

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FormSupport.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FormSupport.java?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FormSupport.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FormSupport.java
 Tue Aug  5 17:15:10 2008
@@ -41,9 +41,9 @@
     <T> void store(T component, ComponentAction<T> action);
 
     /**
-     * As with [EMAIL PROTECTED] #store(Object, 
org.apache.tapestry5.ComponentAction)}}, but the action is also invoked 
immediately.
-     * This is useful for defining an action that should occur symmetrically 
in both the render request and the form
-     * submission's action request.
+     * As with [EMAIL PROTECTED] #store(Object, 
org.apache.tapestry5.ComponentAction)}}, but the action is also invoked
+     * immediately. This is useful for defining an action that should occur 
symmetrically in both the render request and
+     * the form submission's action request.
      *
      * @param component component against which to trigger the action
      * @param action    the action that will be triggered (and passed the 
component)
@@ -77,4 +77,9 @@
      * @param constraint     additional constraint value, or null for 
validations that don't require a constraint
      */
     void addValidation(Field field, String validationName, String message, 
Object constraint);
+
+    /**
+     * Return true if client validation is enabled for this form, false 
otherwise.
+     */
+    boolean isClientValidationEnabled();
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages.properties?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages.properties
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages.properties
 Tue Aug  5 17:15:10 2008
@@ -1,4 +1,4 @@
-# Copyright 2006, 2007 The Apache Software Foundation
+# Copyright 2006, 2007, 2008 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -30,8 +30,5 @@
 integer-format-exception=The input value '%s' is not parseable as an integer 
value.
 number-format-exception=The input value '%s' is not parseable as a numeric 
value.
 
-# The label/alt text for the icon that is displayed next to each field.
-
-icon-label=[Error]
 
 invalid-email='%2$s' is not a valid email address.
\ No newline at end of file

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_de_DE.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_de_DE.properties?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_de_DE.properties
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_de_DE.properties
 Tue Aug  5 17:15:10 2008
@@ -30,6 +30,3 @@
 integer-format-exception=Die Eingabe '%s' ist kein Zahlenwert.
 number-format-exception=Die Eingabe '%s' ist kein numerischer Wert.
 
-# The label/alt text for the icon that is displayed next to each field.
-
-icon-label=[Fehler]

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_it.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_it.properties?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_it.properties
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_it.properties
 Tue Aug  5 17:15:10 2008
@@ -30,6 +30,3 @@
 integer-format-exception=Il valore di '%s' deve essere un numero intero.
 number-format-exception=Il valore di '%s' deve essere un numero.
 
-# The label/alt text for the icon that is displayed next to each field.
-
-icon-label=[Errore]

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_pt_PT.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_pt_PT.properties?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_pt_PT.properties
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_pt_PT.properties
 Tue Aug  5 17:15:10 2008
@@ -1,4 +1,4 @@
-# Copyright 2006, 2007 The Apache Software Foundation
+# Copyright 2006, 2007, 2008 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -30,6 +30,3 @@
 integer-format-exception=O valor '%s' n\u00e3o \u00e9 um valor inteiro.
 number-format-exception=O valor '%s' n\u00e3o \u00e9 um valor num\u00e9rico.
 
-# The label/alt text for the icon that is displayed next to each field.
-
-icon-label=[Error]

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_zh_CN.properties
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_zh_CN.properties?rev=683056&r1=683055&r2=683056&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_zh_CN.properties
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/ValidationMessages_zh_CN.properties
 Tue Aug  5 17:15:10 2008
@@ -1,4 +1,4 @@
-# Copyright 2006, 2007 The Apache Software Foundation
+# Copyright 2006, 2007, 2008 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -12,9 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# The label/alt text for the icon that is displayed next to each field.
-icon-label = [\u9519\u8BEF]
-
 # This is where the translator messages go.
 integer-format-exception = 
'%s'\u7684\u5185\u5BB9\u5FC5\u987B\u662F\u6574\u6570\u3002
 


Reply via email to