Example usage for org.apache.wicket.extensions.markup.html.repeater.data.table.filter FilterToolbar FilterToolbar

List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table.filter FilterToolbar FilterToolbar

Introduction

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

Prototype

public <T, S, F> FilterToolbar(final DataTable<T, S> table, final FilterForm<F> form) 

Source Link

Document

Constructor

Usage

From source file:de.alpharogroup.wicket.data.provider.examples.datatable.DataTablePanel.java

License:Apache License

public DataTablePanel(final String id) {
    super(id);//from ww w .  j  a va  2 s. co m

    final SortableFilterPersonDataProvider dataProvider = new SortableFilterPersonDataProvider(
            PersonDatabaseManager.getInstance().getPersons()) {
        private static final long serialVersionUID = 1L;

        @Override
        public List<Person> getData() {
            final List<Person> persons = PersonDatabaseManager.getInstance().getPersons();
            setData(persons);
            return persons;
        }
    };
    dataProvider.setSort("firstname", SortOrder.ASCENDING);

    final List<IColumn<Person, String>> columns = new ArrayList<>();

    columns.add(new AbstractColumn<Person, String>(new Model<>("Actions")) {
        /**
         * The serialVersionUID
         */
        private static final long serialVersionUID = 1L;

        /**
         * {@inheritDoc}
         */
        @Override
        public void populateItem(final Item<ICellPopulator<Person>> cellItem, final String componentId,
                final IModel<Person> model) {
            final ActionPanel<Person> editActionPanel = new ActionPanel<Person>(componentId, model) {

                /**
                 * The serialVersionUID
                 */
                private static final long serialVersionUID = 1L;

                /**
                 * {@inheritDoc}
                 */
                @Override
                protected IModel<String> newActionLinkLabelModel() {
                    return ResourceModelFactory.newResourceModel("global.main.button.edit.label");
                }

                /**
                 * {@inheritDoc}
                 */
                @Override
                protected void onAction(final AjaxRequestTarget target) {
                    DataTablePanel.this.onEdit(target);
                }

            };
            cellItem.add(editActionPanel);
        }
    });

    columns.add(new PropertyColumn<Person, String>(Model.of("First name"), "firstname", "firstname"));
    columns.add(new PropertyColumn<Person, String>(Model.of("Last Name"), "lastname", "lastname") {
        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return "last-name";
        }
    });
    columns.add(new PropertyColumn<Person, String>(Model.of("Date of birth"), "dateOfBirth", "dateOfBirth"));

    final DataTable<Person, String> tableWithFilterForm = new DataTable<>("tableWithFilterForm", columns,
            dataProvider, 10);
    tableWithFilterForm.setOutputMarkupId(true);

    final FilterForm<PersonFilter> filterForm = new FilterForm<>("filterForm", dataProvider);
    filterForm.add(new TextField<>("dateFrom", PropertyModel.of(dataProvider, "filterState.dateFrom")));
    filterForm.add(new TextField<>("dateTo", PropertyModel.of(dataProvider, "filterState.dateTo")));
    add(filterForm);

    final FilterToolbar filterToolbar = new FilterToolbar(tableWithFilterForm, filterForm);
    tableWithFilterForm.addTopToolbar(filterToolbar);
    tableWithFilterForm.addTopToolbar(new NavigationToolbar(tableWithFilterForm));
    tableWithFilterForm.addTopToolbar(new HeadersToolbar<>(tableWithFilterForm, dataProvider));
    filterForm.add(tableWithFilterForm);
}

From source file:de.alpharogroup.wicket.data.provider.examples.datatable.DefaultDataTablePanel.java

License:Apache License

public DefaultDataTablePanel(final String id) {
    super(id);/*from   w  ww. ja  va  2s.co m*/
    final List<Person> persons = PersonDatabaseManager.getInstance().getPersons();

    final SortableFilterPersonDataProvider dataProvider = new SortableFilterPersonDataProvider(persons) {

        private static final long serialVersionUID = 1L;

        @Override
        public List<Person> getData() {
            return PersonDatabaseManager.getInstance().getPersons();
        }
    };
    final List<IColumn<Person, String>> columns = new ArrayList<>();
    columns.add(new TextFilteredPropertyColumn<Person, PersonFilter, String>(Model.of("First name"),
            "firstname", "firstname"));
    columns.add(new TextFilteredPropertyColumn<Person, PersonFilter, String>(Model.of("Last Name"), "lastname",
            "lastname"));
    columns.add(new PropertyColumn<Person, String>(Model.of("Date of birth"), "dateOfBirth", "dateOfBirth"));

    final FilterForm<PersonFilter> form = new FilterForm<>("form", dataProvider);
    form.add(new TextField<>("firstname", PropertyModel.of(dataProvider, "filterState.firstname")));

    final DefaultDataTable<Person, String> dataTable = new DefaultDataTable<>("dataTable", columns,
            dataProvider, 10);
    dataTable.addTopToolbar(new FilterToolbar(dataTable, form));
    form.add(dataTable);

    add(form);
}

From source file:org.devgateway.toolkit.forms.wicket.page.lists.AbstractListPage.java

License:Open Source License

@Override
protected void onInitialize() {
    super.onInitialize();

    if (jpaRepository == null) {
        throw new NullJpaRepositoryException();
    }//from   w  w w  .  j  av  a2s.c  om
    if (editPageClass == null) {
        throw new NullEditPageClassException();
    }

    SortableJpaRepositoryDataProvider<T> dataProvider = getProvider();
    dataProvider.setFilterState(newFilterState());

    // add the 'Edit' button
    columns.add(new AbstractColumn<T, String>(new StringResourceModel("actionsColumn", this, null)) {
        private static final long serialVersionUID = -7447601118569862123L;

        @Override
        public void populateItem(final Item<ICellPopulator<T>> cellItem, final String componentId,
                final IModel<T> model) {
            cellItem.add(getActionPanel(componentId, model));
        }
    });
    dataTable = new AjaxFallbackBootstrapDataTable<>("table", columns, dataProvider, WebConstants.PAGE_SIZE);

    ResettingFilterForm<JpaFilterState<T>> filterForm = new ResettingFilterForm<>("filterForm", dataProvider,
            dataTable);
    filterForm.add(dataTable);
    add(filterForm);

    if (hasFilteredColumns()) {
        dataTable.addTopToolbar(new FilterToolbar(dataTable, filterForm));
    }

    PageParameters pageParameters = new PageParameters();
    pageParameters.set(WebConstants.PARAM_ID, null);

    editPageLink = new BootstrapBookmarkablePageLink<T>("new", editPageClass, pageParameters,
            Buttons.Type.Success);
    editPageLink.setIconType(FontAwesomeIconType.plus_circle).setSize(Size.Large)
            .setLabel(new StringResourceModel("new", AbstractListPage.this, null));

    add(editPageLink);
}

From source file:wicket.contrib.phonebook.web.page.ListContactsPage.java

License:Apache License

/**
 * Constructor. Having this constructor public means that the page is 'bookmarkable' and hence
 * can be called/ created from anywhere.
 *//*from  ww w . j a  va 2  s.c  o  m*/
public ListContactsPage() {

    super();

    addCreateLink();

    // set up data provider
    ContactsDataProvider dataProvider = new ContactsDataProvider(dao);

    // create the form used to contain all filter components
    final FilterForm<Contact> form = new FilterForm<Contact>("filter-form", dataProvider) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit() {
            users.setCurrentPage(0);
        }
    };

    form.add(new Button("delete-selected") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            for (Long selectedContactId : selectedContactIds) {
                dao.delete(selectedContactId);
            }
            // clear out the set, we no longer need the selection
            selectedContactIds.clear();
        }
    });

    // create the data table
    users = new DefaultDataTable<>("users", createColumns(), dataProvider, 10);
    users.addTopToolbar(new FilterToolbar(users, form));

    form.add(users);

    add(form);
}