Author: ivaynberg
Date: Thu Jul 14 05:35:20 2011
New Revision: 1146564
URL: http://svn.apache.org/viewvc?rev=1146564&view=rev
Log:
Issue: WICKET-3901
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
URL:
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java?rev=1146564&r1=1146563&r2=1146564&view=diff
==============================================================================
---
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
(original)
+++
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
Thu Jul 14 05:35:20 2011
@@ -988,6 +988,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()
+ {
+
+ }
+
+ /**
* Process the form. Though you can override this method to provide
your whole own algorithm, it
* is not recommended to do so.
* <p>
@@ -1034,6 +1050,13 @@ public class Form<T> extends WebMarkupCo
// Update model using form data
updateFormComponentModels();
+ onValidateModelObjects();
+ if (hasError())
+ {
+ callOnError();
+ return false;
+ }
+
// Persist FormComponents if requested
persistFormComponentData();