Author: ivaynberg Date: Sun Jun 5 04:50:23 2011 New Revision: 1131654 URL: http://svn.apache.org/viewvc?rev=1131654&view=rev Log: inner forms should be processed post-order (deepest first) since outer form values can depend on inner form. eg a form inside a formcomponent should have its inputs converted first so they can be used by formcomponent. Issue: WICKET-3765
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=1131654&r1=1131653&r2=1131654&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 Sun Jun 5 04:50:23 2011 @@ -1138,12 +1138,13 @@ public class Form<T> extends WebMarkupCo { // use form of submitting component for processing processingForm = submittingComponent.getForm(); - - if(processingForm == null) + + if (processingForm == null) { - throw new IllegalStateException("submitting component must not return 'null' on getForm()"); + throw new IllegalStateException( + "submitting component must not return 'null' on getForm()"); } - + // invoke submit on component submittingComponent.onSubmit(); } @@ -1151,7 +1152,7 @@ public class Form<T> extends WebMarkupCo { processingForm = this; } - + // invoke Form#onSubmit(..) going from innermost to outermost Visits.visitPostOrder(processingForm, new IVisitor<Form<?>, Void>() { @@ -1709,13 +1710,13 @@ public class Form<T> extends WebMarkupCo */ protected final void validate() { + // since this method can be called directly by users, this additional check is needed if (isEnabledInHierarchy() && isVisibleInHierarchy()) { - // since this method can be called directly by users, this additional check is needed + validateNestedForms(); validateComponents(); validateFormValidators(); onValidate(); - validateNestedForms(); } } @@ -1835,22 +1836,25 @@ public class Form<T> extends WebMarkupCo */ private void validateNestedForms() { - visitChildren(Form.class, new IVisitor<Form<?>, Void>() + Visits.visitPostOrder(this, new IVisitor<Form<?>, Void>() { public void component(final Form<?> form, final IVisit<Void> visit) { + if (form == Form.this) + { + // skip self, only process children + visit.stop(); + return; + } + if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy()) { form.validateComponents(); form.validateFormValidators(); form.onValidate(); } - else - { - visit.dontGoDeeper(); - } } - }); + }, new ClassVisitFilter(Form.class)); }