Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WICKET-7134 Form code refactoring #1047

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ protected void delegateSubmit(IFormSubmitter submittingComponent)
// collect all forms innermost to outermost before any hierarchy is changed
final List<Form<?>> forms = Generics.newArrayList(3);
visitFormsPostOrder(processingForm, (form, visit) -> {
if (form.isSubmitted())
if (form.isVisibleInHierarchy() && form.isEnabledInHierarchy())
{
forms.add(form);
}
Expand Down Expand Up @@ -1557,22 +1557,9 @@ public void component(final FormComponent<?> formComponent, IVisit<Void> visit)
* Mark each form component on this form and on nested forms valid.
*/
protected final void markFormComponentsValid()
{
markNestedFormComponentsValid();
internalMarkFormComponentsValid();
}

/**
* Mark each form component on nested form valid.
*/
private void markNestedFormComponentsValid()
{
visitFormsPostOrder(this, (form, visit) -> {
if (form == Form.this)
{
return;
}
if (form.isSubmitted())
if (form.isVisibleInHierarchy() && form.isEnabledInHierarchy())
{
form.internalMarkFormComponentsValid();
}
Expand Down Expand Up @@ -1879,24 +1866,9 @@ protected void onSubmit()
* @see org.apache.wicket.markup.html.form.FormComponent#updateModel()
*/
protected final void updateFormComponentModels()
{
updateNestedFormComponentModels();
internalUpdateFormComponentModels();
}

/**
* Update the model of all components on nested forms.
*
* @see #updateFormComponentModels()
*/
private void updateNestedFormComponentModels()
{
visitFormsPostOrder(this, (form, visit) -> {
if (form == Form.this)
{
return;
}
if (form.isSubmitted())
if (form.isVisibleInHierarchy() && form.isEnabledInHierarchy())
{
form.internalUpdateFormComponentModels();
}
Expand Down Expand Up @@ -1924,14 +1896,15 @@ private void internalUpdateFormComponentModels()
*/
protected final void validate()
{
// since this method can be called directly by users, this additional check is needed
if (isEnabledInHierarchy() && isVisibleInHierarchy())
{
validateNestedForms();
validateComponents();
validateFormValidators();
onValidate();
}
visitFormsPostOrder(this, (form, visit) -> {
// since this method can be called directly by users, this additional check is needed
if (form.isVisibleInHierarchy() && form.isEnabledInHierarchy())
{
form.validateComponents();
form.validateFormValidators();
form.onValidate();
}
});
}

/**
Expand All @@ -1949,16 +1922,11 @@ protected void onValidate()
private void internalOnValidateModelObjects()
{
visitFormsPostOrder(this, (form, visit) -> {
if (form == Form.this)
{
return;
}
if (form.isSubmitted())
if (form.isVisibleInHierarchy() && form.isEnabledInHierarchy())
{
form.onValidateModelObjects();
}
});
onValidateModelObjects();
}

/**
Expand Down Expand Up @@ -2055,28 +2023,6 @@ protected final void validateFormValidators()
}
}

/**
* Validates {@link FormComponent}s as well as {@link IFormValidator}s in nested {@link Form}s.
*
* @see #validate()
*/
private void validateNestedForms()
{
visitFormsPostOrder(this, (form, visit) -> {
if (form == Form.this)
{
return;
}

if (form.isSubmitted())
{
form.validateComponents();
form.validateFormValidators();
form.onValidate();
}
});
}

/**
* Allows to customize input names of form components inside this form.
*
Expand Down