Skip to content
ajcamilo edited this page Dec 26, 2014 · 1 revision

BootstrapPaginator

This component uses the pagination component from bootstrap (http://getbootstrap.com/components/#pagination). It's very useful as it handles all the math and ajax requests when you want to paginate data.

You can see a demo here.

How to use

<nav>
   <ul class="pagination" wicket:id="paginator" />
</nav>
Model<Integer> totalResults = new LoadableDetachableModel<Integer>(){
     protected Integer load() {
         return database.getSalesCount(); // return number of sales
     }
}

new BootstrapPaginator("paginator", totalResults, 20) {
     public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) {
        ...
     }
}

With this example, we created a paginator that works for 20 results per page. The totalResults is just a model that is refreshed with each request, so you don't need to reset the paginator every time you add sales, for example.

Every time the current page is changes, the onPageChange method is called, and you can refresh your table with the corresponding offset.

NOTE: you don't need to add the paginator to ajax target, since it added itself.

Customization

You can customize the behavior of the paginator, just check out the javadoc:

http://premium-minds.github.io/pm-wicket-utils/apidocs/com/premiumminds/webapp/wicket/bootstrap/BootstrapPaginator.html

Clone this wiki locally