In one of my recent projects I had to create Wicket pagination component with one additional functionality allowing user to dynamically change maximum number of items presented on each page.
Finished component will look like below:
Of course I was not going to implement this from the scratch, because most of work had been already done by Wicket authors and commiters in component PagingNavigator. Source of this component as a reference to changes I made can be found here.
The first steps in creating our component:
- add List itemsPerPageValues holding numbers for ‘items per page’ which will be shown to the user allowing him to click and change this value.
- provide default List DEFAULT_ITEMS_PER_PAGE_VALUES, which will be used (what a surprise!) as a default
- give our component reference to the DataView object on which we will execute change items per page method.