Example usage for org.apache.wicket.markup.html.navigation.paging PagingNavigationIncrementLink PagingNavigationIncrementLink

List of usage examples for org.apache.wicket.markup.html.navigation.paging PagingNavigationIncrementLink PagingNavigationIncrementLink

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.navigation.paging PagingNavigationIncrementLink PagingNavigationIncrementLink.

Prototype

public PagingNavigationIncrementLink(final String id, final IPageable pageable, final int increment) 

Source Link

Document

Constructor.

Usage

From source file:com.aipo.mobycket.wicket.markup.html.navigation.paging.CursorPagingNavigator.java

License:Apache License

protected AbstractLink newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) {
    return new PagingNavigationIncrementLink<Void>(id, pageable, increment);
}

From source file:com.eltiland.ui.common.components.navigator.PagingNavigator.java

License:Apache License

/**
 * Create a new increment link. May be subclassed to make use of specialized links, e.g. Ajaxian
 * links.//from  ww  w .j  ava 2 s  .  com
 *
 * @param id        the link id
 * @param pageable  the pageable to control
 * @param increment the increment
 * @return the increment link
 */
protected AbstractLink newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) {
    return new PagingNavigationIncrementLink<Void>(id, pageable, increment);
}

From source file:com.marc.lastweek.web.components.paginator.VerticalFancyPaginator.java

License:Open Source License

public VerticalFancyPaginator(String id, final IPageable pageableList) {
    super(id);//from  w ww .  j a va  2  s  .c o m

    this.setOutputMarkupId(true);

    System.out.println("current: " + pageableList.getCurrentPage());

    WebMarkupContainer paginatorBox = new WebMarkupContainer("paginatorBox") {
        private static final long serialVersionUID = -8245214604885147260L;

        @Override
        public boolean isVisible() {
            return pageableList.getPageCount() > 1;
        }
    };
    this.add(paginatorBox);

    PagingNavigationLink firstPageLink = new PagingNavigationLink("firstPageLink", pageableList, 0);
    paginatorBox.add(firstPageLink);
    PagingNavigationLink lastPageLink = new PagingNavigationLink("lastPageLink", pageableList,
            pageableList.getPageCount() - 1);
    lastPageLink.add(new Label("lastPageLabel", new Model(Integer.valueOf(pageableList.getPageCount()))));
    paginatorBox.add(lastPageLink);

    // Before current page
    WebMarkupContainer beforeCurrenPageItem = new WebMarkupContainer("beforeCurrentPageItem") {
        private static final long serialVersionUID = -5876391261093967497L;

        @Override
        public boolean isVisible() {
            return pageableList.getCurrentPage() >= 2;
        }
    };
    beforeCurrenPageItem.setOutputMarkupPlaceholderTag(true);
    PagingNavigationIncrementLink beforeCurrentPageLink = new PagingNavigationIncrementLink(
            "beforeCurrentPageLink", pageableList, -1);
    beforeCurrentPageLink.add(new Label("beforeCurrentPageLabel", new LoadableDetachableModel() {
        private static final long serialVersionUID = -3157979806031118522L;

        @Override
        protected Object load() {
            return Integer.valueOf(pageableList.getCurrentPage());
        }
    }));
    beforeCurrenPageItem.add(beforeCurrentPageLink);
    paginatorBox.add(beforeCurrenPageItem);

    // Current page
    WebMarkupContainer currenPageItem = new WebMarkupContainer("currentPageItem") {
        private static final long serialVersionUID = -9186596865047783422L;

        @Override
        public boolean isVisible() {
            return pageableList.getCurrentPage() >= 1
                    && pageableList.getCurrentPage() != pageableList.getPageCount() - 1;
        }
    };
    currenPageItem.setOutputMarkupPlaceholderTag(true);
    currenPageItem.add(new Label("currentPageLabel", new LoadableDetachableModel() {
        private static final long serialVersionUID = 393829273382282502L;

        @Override
        protected Object load() {
            return Integer.valueOf(pageableList.getCurrentPage() + 1);
        }
    }));
    paginatorBox.add(currenPageItem);

    // After CurrentPage
    WebMarkupContainer afterCurrenPageItem = new WebMarkupContainer("afterCurrentPageItem") {
        private static final long serialVersionUID = 7079913736005869990L;

        @Override
        public boolean isVisible() {
            return pageableList.getCurrentPage() < (pageableList.getPageCount() - 2);
        }
    };
    afterCurrenPageItem.setOutputMarkupPlaceholderTag(true);
    PagingNavigationIncrementLink afterCurrentPageLink = new PagingNavigationIncrementLink(
            "afterCurrentPageLink", pageableList, 1);
    afterCurrentPageLink.add(new Label("afterCurrentPageLabel", new LoadableDetachableModel() {
        private static final long serialVersionUID = 8932718471553075655L;

        @Override
        protected Object load() {
            return Integer.valueOf(pageableList.getCurrentPage() + 2);
        }
    }));
    afterCurrenPageItem.add(afterCurrentPageLink);
    paginatorBox.add(afterCurrenPageItem);

    // Two After CurrentPage
    WebMarkupContainer twoAfterCurrenPageItem = new WebMarkupContainer("twoAfterCurrentPageItem") {
        private static final long serialVersionUID = 572789655450253585L;

        @Override
        public boolean isVisible() {
            return pageableList.getCurrentPage() < (pageableList.getPageCount() - 3);
        }
    };
    twoAfterCurrenPageItem.setOutputMarkupPlaceholderTag(true);
    PagingNavigationIncrementLink twoAfterCurrentPageLink = new PagingNavigationIncrementLink(
            "twoAfterCurrentPageLink", pageableList, 2);
    twoAfterCurrentPageLink.add(new Label("twoAfterCurrentPageLabel", new LoadableDetachableModel() {
        private static final long serialVersionUID = 8932718471553075655L;

        @Override
        protected Object load() {
            return Integer.valueOf(pageableList.getCurrentPage() + 3);
        }
    }));
    twoAfterCurrenPageItem.add(twoAfterCurrentPageLink);
    paginatorBox.add(twoAfterCurrenPageItem);

    // Previous and next links
    WebMarkupContainer previousPageItem = new WebMarkupContainer("previousPageItem") {
        private static final long serialVersionUID = -5827228260699397983L;

        @Override
        public boolean isVisible() {
            return pageableList.getCurrentPage() > 0;
        }
    };
    previousPageItem.add(new PagingNavigationIncrementLink("previousPageLink", pageableList, -1));
    previousPageItem.setOutputMarkupPlaceholderTag(true);
    paginatorBox.add(previousPageItem);

    WebMarkupContainer nextPageItem = new WebMarkupContainer("nextPageItem") {
        private static final long serialVersionUID = -5827228260699397983L;

        @Override
        public boolean isVisible() {
            return pageableList.getCurrentPage() < (pageableList.getPageCount() - 1);
        }
    };
    nextPageItem.add(new PagingNavigationIncrementLink("nextPageLink", pageableList, 1));
    nextPageItem.setOutputMarkupPlaceholderTag(true);
    paginatorBox.add(nextPageItem);
}

From source file:com.norconex.commons.wicket.bootstrap.table.BootstrapPagingNavigator.java

License:Apache License

@Override
protected AbstractLink newPagingNavigationIncrementLink(String id, IPageable pageable, int increment) {
    ExternalLink navCont = new ExternalLink(id + "Cont", (String) null);

    // add css for enable/disable link
    long pageIndex = pageable.getCurrentPage() + increment;
    navCont.add(new AttributeModifier("class", new BootstrapPageLinkIncrementCssModel(pageable, pageIndex)));

    // change original wicket-link, so that it always generates href
    navCont.add(new PagingNavigationIncrementLink<Void>(id, pageable, increment));
    return navCont;
}

From source file:de.javakaffee.msm.bench.ListLightPage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 * //from w  ww  .  j  a va  2 s .c om
 * @param parameters
 *            Page parameters
 */
public ListLightPage(final PageParameters parameters) {

    setStatelessHint(true);

    // Add the simplest type of label
    add(new Label("message",
            "Just a list of lightweight items. They're not stored directly in the session, but only their ids."));

    final int page = parameters.getInt("page", 1) - 1;
    final String sortProperty = parameters.getString("orderby", "firstName");
    final boolean ascending = parameters.getAsBoolean("asc", true);
    final SortableContactDataProvider dp = new SortableContactDataProvider(sortProperty, ascending);

    final DataView<Contact> dataView = new DataView<Contact>("sorting", dp) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Contact> item) {
            final Contact contact = item.getModelObject();
            item.add(new ActionPanel("actions", item.getModel()));
            item.add(new Label("contactid", String.valueOf(contact.getId())));
            item.add(new Label("firstname", contact.getFirstName()));
            item.add(new Label("lastname", contact.getLastName()));
            item.add(new Label("homephone", contact.getHomePhone()));
            item.add(new Label("cellphone", contact.getCellPhone()));

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };

    dataView.setItemsPerPage(8);

    dataView.setCurrentPage(page);

    add(new MyOrderByBorder("orderById", "id", dp));

    add(new MyOrderByBorder("orderByFirstName", "firstName", dp));

    add(new MyOrderByBorder("orderByLastName", "lastName", dp));

    add(dataView);

    add(new PagingNavigator("navigator", dataView) {
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         * 
         * @see
         * org.apache.wicket.markup.html.navigation.paging.PagingNavigator
         * #newPagingNavigationIncrementLink(java.lang.String,
         * org.apache.wicket.markup.html.navigation.paging.IPageable, int)
         */
        @Override
        protected AbstractLink newPagingNavigationIncrementLink(final String id, final IPageable pageable,
                final int increment) {
            return new PagingNavigationIncrementLink<Void>(id, pageable, increment) {
                private static final long serialVersionUID = 1L;

                /*
                 * (non-Javadoc)
                 * 
                 * @seeorg.apache.wicket.markup.html.navigation.paging.
                 * PagingNavigationIncrementLink#onClick()
                 */
                @Override
                public void onClick() {
                    throw new UnsupportedOperationException("OnClick not supported by bookmarkable link");
                }

                /*
                 * (non-Javadoc)
                 * 
                 * @see org.apache.wicket.markup.html.link.Link#getURL()
                 */
                @Override
                protected CharSequence getURL() {
                    final PageParameters params = new PageParameters();
                    final SortParam sort = dp.getSort();
                    params.add("page", String.valueOf(getPageNumber() + 1));
                    params.add("orderby", sort.getProperty());
                    params.add("asc", String.valueOf(sort.isAscending()));

                    return urlFor(ListLightPage.class, params);
                }

                /*
                 * (non-Javadoc)
                 * 
                 * @see
                 * org.apache.wicket.markup.html.link.Link#getStatelessHint
                 * ()
                 */
                @Override
                protected boolean getStatelessHint() {
                    return true;
                }

            };
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * org.apache.wicket.markup.html.navigation.paging.PagingNavigator
         * #newPagingNavigationLink(java.lang.String,
         * org.apache.wicket.markup.html.navigation.paging.IPageable, int)
         */
        @Override
        protected AbstractLink newPagingNavigationLink(final String id, final IPageable pageable,
                final int pageNumber) {
            return new MyPagingNavigationLink<Void>(id, pageable, pageNumber, dp);
        }

        /*
         * (non-Javadoc)
         * 
         * @see
         * org.apache.wicket.markup.html.navigation.paging.PagingNavigator
         * #newNavigation
         * (org.apache.wicket.markup.html.navigation.paging.IPageable,
         * org.apache
         * .wicket.markup.html.navigation.paging.IPagingLabelProvider)
         */
        @Override
        protected PagingNavigation newNavigation(final IPageable pageable,
                final IPagingLabelProvider labelProvider) {
            return new PagingNavigation("navigation", pageable, labelProvider) {
                private static final long serialVersionUID = 1L;

                /*
                 * (non-Javadoc)
                 * 
                 * @seeorg.apache.wicket.markup.html.navigation.paging.
                 * PagingNavigation
                 * #newPagingNavigationLink(java.lang.String,
                 * org.apache.wicket
                 * .markup.html.navigation.paging.IPageable, int)
                 */
                @Override
                protected AbstractLink newPagingNavigationLink(final String id, final IPageable pageable,
                        final int pageIndex) {
                    return new MyPagingNavigationLink<Void>(id, pageable, pageIndex, dp);
                }

            };
        }

    });
}