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.
bester quotenvergleich
My web blog; ohne oasis sportwetten (Malissa)
sportwetten steuern
Take a look at my web blog: Basketball Wett Tipps
sportwetten verluste zurückholen österreich
Here is my website … Schweiz online wetten
kombiwette ein spiel falsch
Also visit my site – Best wettanbieter
doppelte chance wetten
My site … sportwetten ohne oasis (Lonna)
sportwetten tipps profi
my page Wetten dass online Spielen
Sportwetten Bonus Paypal; Emmanuelletizon.Zici.Fr, live ergebnisse
wettquote deutschland
Stop by my webpage – mit sportwetten Bonus geld verdienen
sportwetten österreich rechtslage
Here is my web site – beste online buchmacher [directorio.pucv.cl]
schüsse aufs tor wetten
my webpage :: die Besten Sportwetten Anbieter
beste online Wetten beste anbieter wettseite
pferderennen wetten online erklärung
wetten england schweiz
my page – sportwetten bonus angebote (https://namibia.h-we.com/541212/beste-tipps-fuballwetten/)
sportwetten vorhersage app, Julius,
prognose heute
wir wetten erfahrungen
Also visit my site – sichere Kombiwetten
kostenlos pferderennen wetten Strategie, http://www.dinamomultimedia.com, ohne einzahlung
wett tipps für sportwetten heute; Dpanell.com, heute
net
sportwetten tipps profi
Also visit my blog post – wetten ohne einzahlung österreich, Pamela,
wettanbieter mit lizenz in deutschland
Stop by my web-site: Sportwett seiten
gute online wettanbieter
Also visit my web blog Sportwetten anbieter ohne wettsteuer
Good post. I certainly appreciate this site.
Continue the good work!
Also visit my blog: goplayslots.net
online betting Casino Roulette games australia free,
best bingo sites usa 2021 and best real money pokies australia with neosurf, or united statesn roulette spins
beste quoten für sportwetten
my web site: vermittler von wetten bei pferderennen
sportwetten für heute
Look into my web site – wettseiten
wie funktionieren live wetten auf tore
Beste Quoten sportwetten seite für sportwetten
seriöse sportwetten tipps
Here is my web page welche wettanbieter haben eine deutsche
lizenz (Shannan)
uk casino no deposit bonus no wagering, top canadian casinos in axis and canadian casinos still accepting skrill,
or newest online casino usa
my webpage … Goplayslots.net
xpokies no deposit bonus codes australia 2021, casinos uk and
uk best online slots, or best payout online slots australia
my site; ok google how Do you play baccarat
sportwetten strategie hohe quoten
Also visit my webpage gute online wettanbieter (Candice)