2
votes

If I hide and disable a Wicket form, do I need to double-check the visibility conditions in my onSubmit? (Just like we do in JS validation versus Server validations?)

Consider this Wicket snippet:

public class TestPage extends WebPage {
    public TestPage() {
        boolean editable = checkIfUserCanEdit();
        add(new TestForm()
                .setEditable(false)
                .setVisible(false));
    }
}
public static class TestForm {
    ...
    public void onSubmit() {
        if (!checkIfUserCanEdit()) abort(); // Is this necessary?
        ...
    }
}

Do I need the "revalidation" in my onSubmit?

1

1 Answers

2
votes

Looking at the call hierarchy of onSubmit() one comes across

protected void delegateSubmit(IFormSubmitter submittingComponent)
[...]
    public void component(Form<?> form, IVisit<Void> visit)
    {
        if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy())
        {
            form.onSubmit();
        }
    }
[...]

Given that I'd say, no need to protect any further.