Author: ivaynberg
Date: Thu Jul 14 05:40:49 2011
New Revision: 1146568

URL: http://svn.apache.org/viewvc?rev=1146568&view=rev
Log:

Issue: WICKET-3901

Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java?rev=1146568&r1=1146567&r2=1146568&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
 Thu Jul 14 05:40:49 2011
@@ -806,6 +806,13 @@ public class Form<T> extends WebMarkupCo
                        // Update model using form data
                        updateFormComponentModels();
 
+                       // validate model objects after input values have been 
bound
+                       onValidateModelObjects();
+                       if (hasError())
+                       {
+                               callOnError(submittingComponent);
+                       }
+
                        // Form has no error
                        delegateSubmit(submittingComponent);
                }
@@ -1729,6 +1736,22 @@ public class Form<T> extends WebMarkupCo
        }
 
        /**
+        * Called after form components have updated their models. This is a 
late-stage validation that
+        * allows outside frameworks to validate any beans that the form is 
updating.
+        * 
+        * This validation method is not preferred because at this point any 
errors will not unroll any
+        * changes to the model object, so the model object is in a modified 
state potentially
+        * containing illegal values. However, with external frameworks there 
may not be an alternate
+        * way to validate the model object. A good example of this is a JSR303 
Bean Validator
+        * validating the model object to check any class-level constraints, in 
order to check such
+        * constaints the model object must contain the values set by the user.
+        */
+       protected void onValidateModelObjects()
+       {
+
+       }
+
+       /**
         * Triggers type conversion on form components
         */
        protected final void validateComponents()


Reply via email to