To validate a form component after page load add the following to the page
Code Block |
---|
... protected void onBeforeRender() { super.onBeforeRender(); visitChildren(FormComponent.class, new IVisitor() { public Object component(Component component) { FormComponent formComponent = (FormComponent) component; if (formComponent.isRequired()) { // This can be any validator formComponent.error((IValidationError)new ValidationError().addMessageKey("Required")); } return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER; } }); } ... |