Example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable visitChildren

List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable visitChildren

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable visitChildren.

Prototype

public final <R> R visitChildren(final IVisitor<Component, R> visitor) 

Source Link

Document

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

Usage

From source file:com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn.java

License:Apache License

/**
 * This method is called after select all checkbox is clicked
 * @param target/* www.j  a  v  a 2 s  .  c o  m*/
 * @param selected
 * @param table
 */
protected void onUpdateHeader(AjaxRequestTarget target, boolean selected, DataTable table) {
    IDataProvider provider = table.getDataProvider();
    if (!(provider instanceof BaseSortableDataProvider)) {
        LOGGER.debug("Select all checkbox work only with {} provider type. Current provider is type of {}.",
                new Object[] { BaseSortableDataProvider.class.getName(), provider.getClass().getName() });
    }

    //update selected flag in model dto objects based on select all header state
    BaseSortableDataProvider baseProvider = (BaseSortableDataProvider) provider;
    List<T> objects = baseProvider.getAvailableData();
    for (T object : objects) {
        if (object instanceof Selectable) {
            Selectable selectable = (Selectable) object;
            selectable.setSelected(selected);
        }
    }

    //refresh rows with ajax
    ComponentHierarchyIterator iterator = table.visitChildren(SelectableDataTable.SelectableRowItem.class);
    while (iterator.hasNext()) {
        SelectableDataTable.SelectableRowItem row = (SelectableDataTable.SelectableRowItem) iterator.next();
        if (!row.getOutputMarkupId()) {
            //we skip rows that doesn't have outputMarkupId set to true (it would fail)
            continue;
        }
        target.add(row);
    }
}