Example usage for org.apache.wicket.extensions.markup.html.repeater.data.grid ICellPopulator populateItem

List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.grid ICellPopulator populateItem

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.markup.html.repeater.data.grid ICellPopulator populateItem.

Prototype

void populateItem(final Item<ICellPopulator<T>> cellItem, final String componentId, final IModel<T> rowModel);

Source Link

Document

Method used to populate a cell in the DataGridView Implementation MUST add a component to the cellItem using the component id provided by componentId argument, otherwise a WicketRuntimeException will be thrown

Usage

From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.array.RowView.java

License:Open Source License

/**
 * Populate the repeating view with the cell populator, for a given row item.
 * @param item//  w ww . jav  a 2s.co  m
 * @return
 */
@SuppressWarnings("unchecked")
protected void populateCells(RepeatingView cells, Item item) {
    Iterator populators = getPopulatorsIterator();

    for (int i = 0; populators.hasNext(); i++) {
        IModel populatorModel = (IModel) populators.next();
        Item cellItem = newCellItem(cells.newChildId(), i, populatorModel);
        cells.add(cellItem);

        ICellPopulator populator = (ICellPopulator) cellItem.getModelObject();
        populator.populateItem(cellItem, CELL_ITEM_ID, item.getModel());

        if (cellItem.get("cell") == null) {
            throw new WicketRuntimeException(populator.getClass().getName()
                    + ".populateItem() failed to add a component with id [" + CELL_ITEM_ID
                    + "] to the provided [cellItem] object. Make sure you call add() on cellItem ( cellItem.add(new MyComponent(componentId, rowModel) )");
        }
    }
}

From source file:org.sakaiproject.sitestats.tool.wicket.components.paging.infinite.AbstractInfinitePagingDataGridView.java

License:Educational Community License

/**
 * @param item/* w  w w. j ava  2 s .  c  o m*/
 * @see org.apache.wicket.markup.repeater.RefreshingView#populateItem(org.apache.wicket.markup.repeater.Item)
 */
@Override
protected final void populateItem(final Item<T> item) {
    RepeatingView cells = new RepeatingView(CELL_REPEATER_ID);
    item.add(cells);

    int populatorsNumber = populators.size();
    for (int i = 0; i < populatorsNumber; i++) {
        ICellPopulator<T> populator = populators.get(i);
        IModel<ICellPopulator<T>> populatorModel = new Model<>(populator);
        Item<ICellPopulator<T>> cellItem = newCellItem(cells.newChildId(), i, populatorModel);
        cells.add(cellItem);

        populator.populateItem(cellItem, CELL_ITEM_ID, item.getModel());

        if (cellItem.get("cell") == null) {
            throw new WicketRuntimeException(populator.getClass().getName()
                    + ".populateItem() failed to add a component with id [" + CELL_ITEM_ID
                    + "] to the provided [cellItem] object. Make sure you call add() on cellItem and make sure you gave the added component passed in 'componentId' id. ( *cellItem*.add(new MyComponent(*componentId*, rowModel) )");
        }
    }
}

From source file:table.headercolumndatatable.extra.AbstractDataGridView.java

License:Apache License

private void populate(Item<T> rowItem, WebMarkupContainer container, IModel<ICellPopulator<T>> cellPopulator,
        int i, String newChildId, String componentId) {
    Item<ICellPopulator<T>> cellItem = newCellItem(newChildId, i, cellPopulator);
    container.add(cellItem);//w ww.  ja v  a  2s.  co  m

    ICellPopulator<T> populator = cellItem.getModelObject();
    populator.populateItem(cellItem, componentId, rowItem.getModel());
}