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.
http://squacre.com/author/karaokednm531/
sportwetten strategie system
My blog post basketball pro a wetten; Carlo,
https://pixabay.com/users/u_f6mmilfcu8-58008064/
https://www.sosyalciniz.net/author/warhyc143/
online wette
Have a look at my site :: Wetten Basketball Tipps
https://app.readthedocs.org/profiles/madelyn541/
https://www.sosyalciniz.net/author/warhyc143/
https://app.readthedocs.org/profiles/madelyn541/
https://www.lissubito.com/author/establishmentnfn98/
https://www.lissubito.com/author/establishmentnfn98/
https://wakelet.com/@madelyn54140938
https://wakelet.com/@madelyn54140938
wettportal quotenvergleich
my web blog … basketball pro b wetten
https://loriwhitlock.com/author/infectionsty7405/
sportwetten selbst anbieten
My blog :: Basketball Wett Tipps Heute
https://loriwhitlock.com/author/infectionsty7405/
https://manylink.co/@madelyn541
https://uvirtual.edu.co/author/palestinemll5578/
https://manylink.co/@madelyn541
https://manylink.co/@madelyn541
https://uvirtual.edu.co/author/palestinemll5578/
https://uvirtual.edu.co/author/palestinemll5578/
https://www.iniuria.us/forum/member.php?732755-madelyn541
http://bobbysuperstarsensation.com/author/spokegdy75/
https://www.iniuria.us/forum/member.php?732755-madelyn541
https://www.iniuria.us/forum/member.php?732755-madelyn541
http://bobbysuperstarsensation.com/author/spokegdy75/
kasyno online wpłata sofort
Here is my webpage – rekomendowane kasyn z niskim depozytem (http://Www.Richardstrange.com)
kasyna przyjmujące klarna
Look at my website – Legalne Kasyno Online Olsztyn – Parallelcreative.Net,
keno online za pieniądze
Have a look at my homepage; sloty bez depozytu 2026 (https://Przedszkolebajkowyswiat.pl)
https://medibulletin.com/author/birminghammoo1488/
bonus kasynowy wagering 45x
Feel free to visit my web site … darmowe spiny kasyno bitcoin
basketball wetten bei betolimp strategie
400 zł bez depozytu nowe kasyno 300 zł bonus (Esperanza)
https://www.xosothantai.com/members/madelyn541.656327/
https://www.xosothantai.com/members/madelyn541.656327/
https://www.xosothantai.com/members/madelyn541.656327/
poker od 10 groszy
My site :: Graj W JednoręKi Bandyta Online Na PieniąDze
(Https://Goodquestionashtabula.Com/)
https://medibulletin.com/author/birminghammoo1488/
nowe kasyno Depozyt 5 zł visa [http://www.nakedyogalondon.co.uk] 300 zł bonus
https://expathealthseoul.com/profile/madelyn-me/
crazy time live na pieniądze
Feel free to surf to my web blog kasyna przyjmujące tether
https://foodiescancook.com/author/guitarxtu144/
sportwetten bonus code ohne einzahlung
Have a look at my site basketball live wetten
https://www.akaqa.com/question/q19192751582-Gde-kupit-poppers-online
kasyno kryptowaluty opinie
Feel free to surf to my web page … top 3 kasyn z niskim depozytem (Ems-Ksa.com)
horses to bet on cheltenham races
Visit my web site – today s racing results from southwell
- Michaela,
https://www.akaqa.com/question/q19192751582-Gde-kupit-poppers-online
https://foodiescancook.com/author/guitarxtu144/
legalne sloty online
Also visit my blog … top 3 bonusów kasynowych