I couldn’t find a good set of macros to help navigate through paginated data so I wrote my own. The macro names echo the names of the CakePHP PaginationHelper functions because…well, they’re reasonably sensible.
The macros expect you to add a model attribute called “paginationData” which contains (at least) the following properties:
pageNumber -> The current page number
pageSize -> The number of items in each page
pagesAvailable -> The total number of pages
sortDirection -> The sorting direction (ascending or descending)
sortField -> The field currently sorted by
In my implementation, my paginationData also contains a property called “pageItems” – the actual items in this page.
The macros available to you are:
- first
Outputs a link to the first page - last
Outputs a link to the last page - next
Outputs a link to the next page - previous
Outputs a link to the previous page - numbers
Outputs links to other pages. The macro takes a parameter called “maxPages”, which is the maximum number of pages that should be output. There is also a second parameter “separator”, which is the text/html that should be output between each page link. - page
Outputs a link to a particular page. It takes the page number and link text as parameters. If you omit the link text it’ll default to the page number - counter
Outputs the current page number and the total pages e.g. “1 of 20″ - sort
Outputs a link to sort by a field. Takes the field to sort by as its first parameter. If field is different to the current sort field, the link will change the sort field but not the sort direction. If the field is the same as the current sort field, the link will change the sort direction. The second parameter is the link text, which defaults to the field name with an upper case first letter. It also takes a parameter called “directions”. This is an an array of two items: the words being used in paginationData.sortDirection to describe the sorting direction of ascending or descending. Default: ["Asc", "Desc"]. So it can compare the current sorting direction and switch to the converse.
Note, ordinarily you’ll probably not need to use the “page” macro.
How to use
In Java, add a model attribute “paginationData” containing the properties I’ve described above. Then, in your view, import the library:
<#import "pagination.ftl" as pagination />
Call the macros:
<nav style="float:right;">
<@pagination.first />
<@pagination.previous />
<@pagination.numbers />
<@pagination.next />
<@pagination.last />
</nav>
<@pagination.counter />
Which’ll give you something like:
![]()
For table headings that allow sorting:
<table>
<tr>
<th><@pagination.sort "forename" /></th>
<th><@pagination.sort "surname" /></th>
<th><@pagination.sort "email" /></th>
<th><@pagination.sort "created" "Registration date" /></th>
</tr>
...
</table>
Download
You can download the pagination macros here.
https://qpsldsrdaj.wordpress.com
https://cgcnzgfmws.wordpress.com
https://cgcnzgfmws.wordpress.com
https://cgcnzgfmws.wordpress.com
wetten auf tore
Here is my web site … basketball-wetten.com
https://tdocbwwnmc.wordpress.com
sportwetten einzelwetten strategie
Here is my homepage :: wette deutschland europameister; Dominik,
https://tdocbwwnmc.wordpress.com
wetten pferderennen tipps
Feel free to visit my blog beste overwatch wettanbieter
https://tdocbwwnmc.wordpress.com
no deposit australian pokies, online casino paypal deposit usa and 21 dukes red
hot casino game – Marcelo, review, or online casino guide uk
Write more, thats all I have to say. Literally,
it seems as though you relied on the video to make your point.
You clearly know what youre talking about, why throw away your intelligence
on just posting videos to your site when you could be giving us
something enlightening to read?
Here is my webpage casino in vacaville [tuyan.igcmar.com]
https://ivityniavo.wordpress.com
https://ivityniavo.wordpress.com
https://ivityniavo.wordpress.com
sportwetten deutscher meister
Here is my web page :: wettseiten einzahlungsbonus (Josef)
https://wncaclkked.wordpress.com
wetten dass alle folgen online schauen
My page: Beste Sportwetten App deutschland
https://wncaclkked.wordpress.com
https://tpmtulmcmk.wordpress.com
https://tpmtulmcmk.wordpress.com
https://wkbvjijpry.wordpress.com
https://wkbvjijpry.wordpress.com
https://wkbvjijpry.wordpress.com
https://mqhqxisngl.wordpress.com
https://mqhqxisngl.wordpress.com
sinkende quoten wetten
my webpage … eurovision buchmacher (Nilda)
https://vrxuhoyhpk.wordpress.com
https://vrxuhoyhpk.wordpress.com
bet live wetten
my page :: App Sportwetten
https://reowucgwsa.wordpress.com
Heya i’m for the primary time here. I found this board and I in finding It really
useful & it helped me out a lot. I hope to offer something again and help
others like you helped me.
my page – web Site
https://reowucgwsa.wordpress.com
wir wetten deutschland japan (Tanya) erfahrungen
major poker in canada, usa online casino reviews and free spin no
deposit bonus codes usa, or european roulette layout usa
Here is my website – how much money do native american get from Casinos
https://jdutyrirge.wordpress.com
https://jdutyrirge.wordpress.com
https://apfkycjgfb.wordpress.com
united statesn casino no deposit free spins, best usa online casino bonuses and roulette online united states, or milwausaee do casino cash checks poker
https://apfkycjgfb.wordpress.com
https://ficcpnhwqv.wordpress.com
https://ficcpnhwqv.wordpress.com
https://ficcpnhwqv.wordpress.com
https://bbfiuetlig.wordpress.com
https://bbfiuetlig.wordpress.com
https://bbfiuetlig.wordpress.com
https://hbclmjyygw.wordpress.com
https://hbclmjyygw.wordpress.com
https://hbclmjyygw.wordpress.com
https://tdxxfrobpl.wordpress.com