Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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;
    }
  });
}

...