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.
apuestas sin deposito inicial para ganar
dinero
okamžitý vklad stávková kancelária
Look into my page – stávky na Cs2
ako staviť vstupný bonus na Slovensku tenis
united kingdom online pokies lightning link, real usa online casino
and casino in united states, or best free internet blackjack (Saul) casino chips usa
spelsajter online
my web-site – cykel Betting
list of united statesn online casinos, free spins or no deposit bonus
and pokie machines in united states, or new how much does it cost to open Your own casino
slot sites usa
gambling legal in usa, emu casino united
kingdom and rules of casino war – Homer – deposit bonus usa,
or sun bingo uk
boksning odds tips
Look into my homepage; oddsudbyder med dankort
daňový doklad stávková kancelária
Feel free to surf to my web blog :: stávkové kancelárie skúSenosti fórum
bukmacher łączenie kursów
My page; mecz polska usa siatkówka wynik (Linnea)
beste Ios wedden platformen voor geld 2026
gaming club casino usa login, casino united kingdom bonus sans depot and united statesn online casinos 2021 real money, or bet365 united statesn roulette betting
my page :: blackjack chance Of dealer busting
asiatische basketball handicap Wetten tore
altılı ganyan taktikleri
My blog post :: en iyi canlı skor uygulaması (Charmain)
kladionica zadar
Here is my homepage – Bet365 Kvote
30 zł bonus powitalny kasyno
Feel free to surf to my web-site ZakłAd W Kasynie
legal gambling sites in australia, legitimate
online pokies australia and online craps australia, or online ip casino (Beatris) real money canada paysafe
best online betting sites With Cash out (Http://rollsrealtycom.Dupe.aios-Staging.com/) on dogs strategy
serie a odds
Check out my website – sportsbetting app gratis (Jill)
wm odds idag
Feel free to surf to my web site :: spelbolag utan Svensk licens 2026
canadian casino guide different types of blackjack games – Virgie – chart, online slots casino
australia and united statesn real money casino, or where can i play online pokies in united states
echipa de fotbal manchester united
Look at my homepage: Liga 2 Casa Pariurilor
gratis geld online winnende wedden 2026
(Ashley)
expert betting picks
Also visit my blog post – Bookmakers without limits
ryder cup tips
Have a look at my blog post … oddssidor utan spelpaus
langrenn tips
Feel free to visit my web blog :: spilltips i morgen (Merrill)
trygge bookmakere
Also visit my web-site Boostede Odds
new 2021 vegas Baby casino review uk, betsoft no deposit bonus
united kingdom and free online poker united states, or free bingo games no deposit usa
poker casino ervaringen
Feel free to visit my web-site :: beste gokkasten met Hoge rtp
slot machines ontario united states, united kingdom pub pokies and
free casino spins uk, or new zealandn online casino no
deposit bonus 2021
Here is my web-site: how old do you have to be to gamble in punta
cana (Royce)
bettingsider med risikofrit spil
Here is my blog post: bookmaker bonus; http://www.Waynespaintings.com,
beste snooker weddenschap
Feel free to surf to my web-site; Eerlijke Wedden Tips 2026
zaručené tipy na box
bettingsidor utan svensk licens 2026
My web page: nytt oddsbolag (https://thatanitalive.com)
Linia stawek bukmacher – https://Bukmacherjakie.com/ – gdzie najlepiej