cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r231472 - /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
Date Thu, 11 Aug 2005 14:47:30 GMT
Author: vgritsenko
Date: Thu Aug 11 07:47:26 2005
New Revision: 231472

URL: http://svn.apache.org/viewcvs?rev=231472&view=rev
Log:
side effect free set/getValidationError

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java?rev=231472&r1=231471&r2=231472&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
Thu Aug 11 07:47:26 2005
@@ -362,11 +362,11 @@
             if (this.value == null && getFieldDefinition().isRequired()) {
                 // Field is required
                 this.validationError = new ValidationError(new I18nMessage("general.field-required",
Constants.I18N_CATALOGUE));
-            } else {
-                if (super.validate() && value != null) {
-                    // New-style validators were successful. Check the old-style ones.
-                    this.validationError = getDatatype().validate(value, new ExpressionContextImpl(this));
-                }
+            } else if (!super.validate()) {
+                // New-style validators failed.
+            } else if (this.value != null) {
+                // Check the old-style ones.
+                this.validationError = getDatatype().validate(this.value, new ExpressionContextImpl(this));
             }
         } finally {
             // Consider validation finished even in case of exception
@@ -376,11 +376,12 @@
 
     /**
      * Returns the validation error, if any. There will always be a validation error in case
the
-     * {@link #validate()} method returned false.
+     * {@link #validate} method returned false.
+     *
+     * <br>This method does not cause parsing to take effect, use {@link #getValue}
if value
+     * is not parsed yet.
      */
     public ValidationError getValidationError() {
-        // If needed, getValue() will do the validation
-        getValue();
         return this.validationError;
     }
 
@@ -391,7 +392,10 @@
      * @param error the validation error
      */
     public void setValidationError(ValidationError error) {
-        this.valueState = VALUE_DISPLAY_VALIDATION;
+        if (this.valueState >= VALUE_VALIDATED) {
+            this.valueState = VALUE_DISPLAY_VALIDATION;
+        }
+
         if (!ObjectUtils.equals(this.validationError, error)) {
             this.validationError = error;
             getForm().addWidgetUpdate(this);



Mime
View raw message