Example usage for org.apache.wicket.markup.html.panel Panel beforeRender

List of usage examples for org.apache.wicket.markup.html.panel Panel beforeRender

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.panel Panel beforeRender.

Prototype

public final void beforeRender() 

Source Link

Document

THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.

Usage

From source file:com.googlecode.wicketwebbeans.containers.BeanForm.java

License:Apache License

/**
 * Rather than using Wicket's required field validation, which doesn't play well with Ajax and forms,
 * allow validation of fields on actions. User must call this from the action method.
 * Adds errors to the page if empty required fields are found. 
 *
 * @return true if validation was successful, else false if errors were found.
 *//*  w ww  .j  a va2 s  . co  m*/
public boolean validateRequired() {
    RequiredFieldValidator validator = new RequiredFieldValidator();

    // If we have a tabbed panel, we have to go thru each tab and validate it because the components for a tab are only created
    // when the tab is open.
    if (tabbedPanel == null) {
        visitChildren(AbstractField.class, validator);
    } else {
        for (ITab tab : tabbedPanel.getTabs()) {
            Panel panel = tab.getPanel("x");
            // Needs to be part of the page for errors.
            getPage().add(panel);
            // Cause ListViews to be populated.
            panel.beforeRender();
            panel.visitChildren(AbstractField.class, validator);
            getPage().remove(panel);
        }
    }

    return !validator.errorsFound;
}