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

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

Introduction

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

Prototype

public final <S extends Component, R> R visitChildren(final Class<?> clazz, final IVisitor<S, R> visitor) 

Source Link

Document

Traverses all child components of the given class in this container, calling the visitor's visit method at each one.

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.
 *///from ww  w.j a  v a2  s . c  om
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;
}

From source file:org.hippoecm.addon.workflow.AbstractWorkflowManagerPlugin.java

License:Apache License

private List<Panel> buildPanelsForCategories(final MenuHierarchy menu, final Node subject, String[] categories)
        throws RepositoryException {
    List<Panel> list = new ArrayList<>();
    for (final String category : categories) {
        List<Panel> panels = buildPanelsForCategory(subject, category);
        for (Panel panel : panels) {
            panel.visitChildren(Panel.class, new MenuVisitor(menu, category));
            panel.setVisible(false);//  w ww . ja  v a 2  s. c o  m
            list.add(panel);
        }
    }
    return list;
}