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

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

Introduction

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

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:org.onehippo.forge.cms.groovy.plugin.panels.GroovyScriptManagementPanel.java

License:Apache License

public GroovyScriptManagementPanel(String id, IBreadCrumbModel breadCrumbModel) {
    super(id, breadCrumbModel);

    form = new Form("form");

    List<IColumn<?>> columns = new ArrayList<IColumn<?>>();

    columns.add(new PropertyColumn(new Model<String>("Name"), "name", "name"));
    columns.add(new PropertyColumn(new Model<String>("Path"), "path"));
    columns.add(new AbstractColumn(new Model<String>("Actions")) {
        public void populateItem(Item cellItem, String componentId, IModel rowModel) {
            Script script = ((Script) rowModel.getObject());
            cellItem.add(new ActionPanel(componentId, script));
        }//from w  w  w  .  j  a va2 s . c  om
    });

    DataTable table = new DefaultDataTable("datatable", columns, groovyScriptsDataProvider, 10);

    form.add(new AjaxButton("ajax-upload", form) {

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            final FileUpload uploadedFile = fileUpload.getFileUpload();
            if (uploadedFile != null) {
                storeUploadedGroovyScript(uploadedFile);
                target.addComponent(form);
            }
        }
    });

    form.setMultiPart(true);
    form.setOutputMarkupId(true);
    fileUpload = new FileUploadField("fileUpload");
    form.add(fileUpload);
    table.setOutputMarkupId(true);
    form.add(table);
    form.setOutputMarkupId(true);
    add(form);
}

From source file:org.onexus.website.api.widgets.tableviewer.DataTablePanel.java

License:Apache License

public DataTablePanel(String id, final List<? extends IColumn<IEntityTable, String>> columns,
        final EntitiesRowProvider dataProvider, final long defaultRowsPerPage) {
    super(id);/*from   w w w  .j  a  v  a 2s  . co m*/

    this.dataProvider = dataProvider;

    indicator = new WebMarkupContainer("indicator");
    indicator.setOutputMarkupId(true);
    indicator.add(new Image("loading", OnDomReadyPanel.LOADING_IMAGE));
    add(indicator);

    DataTable<IEntityTable, String> resultTable = new DataTable<IEntityTable, String>("datatable", columns,
            dataProvider, defaultRowsPerPage);
    resultTable.setOutputMarkupId(true);
    resultTable.setVersioned(false);
    resultTable.addTopToolbar(new HeadersToolbar(resultTable, dataProvider));
    resultTable.addBottomToolbar(new NoRecordsToolbar(resultTable));
    resultTable.addBottomToolbar(new NavigationToolbar(resultTable));
    add(resultTable);
}

From source file:org.onexus.website.api.widgets.tableviewer.HeadersToolbar.java

License:Apache License

/**
 * Constructor/*  ww  w .j av a2 s. co  m*/
 *
 * @param table        data table this toolbar will be attached to
 * @param stateLocator locator for the ISortState implementation used by sortable
 *                     headers
 */
public <T, S> HeadersToolbar(final DataTable<T, S> table, final ISortStateLocator stateLocator) {
    super(table);

    table.setOutputMarkupId(true);

    RepeatingView headersGrandParents = new RepeatingView("headersGrandParents");
    RepeatingView headersParents = new RepeatingView("headersParents");
    RepeatingView headers = new RepeatingView("headers");

    //TODO Show optionally headers
    headersGrandParents.setVisible(false);
    headersParents.setVisible(false);

    add(headersGrandParents);
    add(headersParents);
    add(headers);

    final List<? extends IColumn<T, S>> columns = table.getColumns();

    WebMarkupContainer secondHeaderContainer = null;
    String lastSecondHeaderTitle = null;
    int lastSecondHeaderColspan = 0;

    WebMarkupContainer thirdHeaderContainer = null;
    String lastThirdHeaderTitle = null;
    int lastThirdHeaderColspan = 0;

    int col = 0;
    for (final IColumn<T, S> c : columns) {

        String placement = col == 0 ? "right" : (col + 1 == columns.size() ? "left" : "top");

        // Process only Track columns
        CollectionColumn column = null;
        if (c instanceof CollectionColumn) {
            column = (CollectionColumn) c;
        } else {

            if (c instanceof AbstractColumn) {
                WebMarkupContainer item = new WebMarkupContainer(headers.newChildId());
                item.setRenderBodyOnly(true);

                WebMarkupContainer parentItem = new WebMarkupContainer(headersParents.newChildId());
                parentItem.setRenderBodyOnly(true);

                WebMarkupContainer grandParentItem = new WebMarkupContainer(headersGrandParents.newChildId());
                grandParentItem.setRenderBodyOnly(true);

                headers.add(item);
                headersParents.add(parentItem);
                headersGrandParents.add(grandParentItem);

                WebMarkupContainer firstHeaderContainer = new WebMarkupContainer("header");

                WebMarkupContainer innerHeader = new WebMarkupContainer("filter");
                innerHeader.add(c.getHeader("label"));
                firstHeaderContainer.add(innerHeader);
                firstHeaderContainer.add(new AttributeModifier("style",
                        new Model<String>("font-size:12px; font-family:sans-serif;")));

                item.add(firstHeaderContainer);

                secondHeaderContainer = new WebMarkupContainer("header");
                decorateSecondParentHeader(secondHeaderContainer, null, column);

                secondHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty")));
                parentItem.add(secondHeaderContainer);
                secondHeaderContainer = null;

                thirdHeaderContainer = new WebMarkupContainer("header");
                thirdHeaderContainer.add(new EmptyPanel("label"));
                thirdHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty")));
                grandParentItem.add(thirdHeaderContainer);
                thirdHeaderContainer = null;
            }

            continue;
        }

        IHeader firstHeader = column.getHeaderDecorator();
        IHeader secondHeader = firstHeader == null ? null : firstHeader.getParentHeader();
        IHeader thirdHeader = secondHeader == null ? null : secondHeader.getParentHeader();

        WebMarkupContainer item = new WebMarkupContainer(headers.newChildId());
        headers.add(item);

        WebMarkupContainer firstHeaderContainer = null;
        if (column.isFilterable()) {
            firstHeaderContainer = new FilteredHeader("header", (FieldHeader) column.getHeaderDecorator());
        } else {
            firstHeaderContainer = new WebMarkupContainer("header");
        }

        WebMarkupContainer innerHeader;
        if (column.isSortable()) {
            innerHeader = newSortableHeader("filter", column.getSortProperty(), stateLocator);
        } else {
            innerHeader = new WebMarkupContainer("filter");
        }
        firstHeaderContainer.add(innerHeader);

        item.add(firstHeaderContainer);
        item.setRenderBodyOnly(true);
        innerHeader.add(firstHeader.getHeader("label"));
        if (firstHeader.getLabel() == null) {
            firstHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty")));
        }

        // Add parent and grand parent headers
        String secondTitle = null;
        String thirdTitle = null;

        firstHeaderContainer.add(new AttributeModifier("title", new Model<String>(firstHeader.getTitle())));
        firstHeaderContainer.add(new AttributeModifier("rel", Model.of("tooltip")));
        firstHeaderContainer.add(new AttributeModifier("data-placement", Model.of(placement)));
        firstHeaderContainer.add(
                new AttributeModifier("style", new Model<String>("font-size:12px; font-family:sans-serif;")));

        if (secondHeader != null) {
            secondTitle = secondHeader.getLabel();
        }
        if (thirdHeader != null) {
            thirdTitle = thirdHeader.getLabel();
        }

        if (secondHeaderContainer != null
                && ((lastSecondHeaderTitle == null && secondTitle == null) || (lastSecondHeaderTitle != null
                        && secondTitle != null && lastSecondHeaderTitle.equals(secondTitle)))) {
            lastSecondHeaderColspan += 1;
            secondHeaderContainer.add(new AttributeModifier("colspan",
                    new Model<String>(Integer.toString(lastSecondHeaderColspan))));

        } else {

            // Add parentItem
            WebMarkupContainer parentItem = new WebMarkupContainer(headersParents.newChildId());
            headersParents.add(parentItem);
            secondHeaderContainer = new WebMarkupContainer("header");
            decorateSecondParentHeader(secondHeaderContainer, secondHeader, column);

            if (secondTitle == null) {
                secondHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty")));
            }

            if (secondHeader != null && secondHeader.getLabel() != null) {
                secondHeaderContainer
                        .add(new AttributeModifier("title", new Model<String>(secondHeader.getTitle())));
                secondHeaderContainer.add(new AttributeModifier("rel", Model.of("tooltip")));
                secondHeaderContainer.add(new AttributeModifier("data-placement", Model.of(placement)));
            }

            secondHeaderContainer.add(new AttributeModifier("style",
                    new Model<String>("font-size:12px; font-family:sans-serif;")));
            parentItem.add(secondHeaderContainer);
            parentItem.setRenderBodyOnly(true);
            lastSecondHeaderTitle = secondTitle;
            lastSecondHeaderColspan = 1;
        }

        // GrandParents
        if (thirdHeaderContainer != null
                && ((lastThirdHeaderTitle == null && thirdTitle == null) || (lastThirdHeaderTitle != null
                        && thirdTitle != null && lastThirdHeaderTitle.equals(thirdTitle)))) {
            lastThirdHeaderColspan += 1;
            thirdHeaderContainer.add(new AttributeModifier("colspan",
                    new Model<String>(Integer.toString(lastThirdHeaderColspan))));
        } else {
            // Add grandParentItem
            WebMarkupContainer grandParentItem = new WebMarkupContainer(headersGrandParents.newChildId());
            headersGrandParents.add(grandParentItem);
            thirdHeaderContainer = new WebMarkupContainer("header");

            if (thirdTitle == null) {
                thirdHeaderContainer.add(new AttributeModifier("class", new Model<String>("empty")));
            }

            if (thirdHeader != null) {
                thirdHeaderContainer.add(thirdHeader.getHeader("label"));

                if (thirdHeader.getLabel() != null) {
                    thirdHeaderContainer
                            .add(new AttributeModifier("title", new Model<String>(thirdHeader.getTitle())));
                    thirdHeaderContainer.add(new AttributeModifier("rel", Model.of("tooltip")));
                    thirdHeaderContainer.add(new AttributeModifier("data-placement", Model.of(placement)));

                }
            } else {
                thirdHeaderContainer.add(new EmptyPanel("label"));
            }

            thirdHeaderContainer.add(new AttributeModifier("style",
                    new Model<String>("font-size:12px; font-family:sans-serif;")));
            grandParentItem.add(thirdHeaderContainer);
            grandParentItem.setRenderBodyOnly(true);
            lastThirdHeaderTitle = thirdTitle;
            lastThirdHeaderColspan = 1;

        }

        col++;

    }
}

From source file:org.ujorm.wicket.component.grid.UjoDataProvider.java

License:Apache License

/** Create AJAX-based DataTable */
public <S> DataTable<T, S> createDataTable(final String id, final int rowsPerPage) {
    final DataTable<T, S> result = new DataTable<T, S>(id, (List) columns, this, rowsPerPage) {
        @Override/*from  ww  w .  j av  a 2s  .  c  o  m*/
        protected Item<T> newRowItem(final String id, final int index, final IModel<T> model) {
            return new OddEvenItem<T>(id, index, model);
        }
    };

    result.addTopToolbar(new AjaxNavigationToolbar(result));
    result.addTopToolbar(new HeadersToolbar(result, this));
    result.addBottomToolbar(new NoRecordsToolbar(result));
    result.setOutputMarkupId(true);
    return result;
}

From source file:ro.nextreports.server.web.core.ViewInfoPanel.java

License:Apache License

private void addParametersTable(ParamViewDataProvider dataProvider) {
    List<IColumn<ParamView, String>> columns = createColumns();
    DataTable<ParamView, String> table = new BaseTable<ParamView>("table", columns, dataProvider, 300);
    table.setOutputMarkupId(true);
    add(table);/*from  w  w  w .ja  v  a2s  .com*/
}

From source file:sk.lazyman.gizmo.component.data.TablePanel.java

License:Apache License

private void initLayout(List<IColumn<T, String>> columns, ISortableDataProvider provider, int rowsPerPage) {
    DataTable<T, String> table = new DataTable<>(ID_TABLE, columns, provider, rowsPerPage);

    table.setOutputMarkupId(true);

    TableHeadersToolbar headers = new TableHeadersToolbar(table, provider);
    headers.setOutputMarkupId(true);/*from  w w  w. j  a va 2  s .c  o  m*/
    table.addTopToolbar(headers);

    CountToolbar count = new CountToolbar(table);
    addVisibleBehaviour(count, showCount);
    table.addBottomToolbar(count);

    add(table);

    NavigatorPanel nb2 = new NavigatorPanel(ID_PAGING, table, true);
    addVisibleBehaviour(nb2, showPaging);
    add(nb2);

    setItemsPerPage(rowsPerPage);
}