FreeMarker pagination macros

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.

742 thoughts on “FreeMarker pagination macros

  1. En réalité, Gates of Olympus ne propose pas 20 lignes de paiement classique mais des ligne de paiement « anywhere ». Le principe est que vous générez un gain dès que huit même symboles sont présents sur les rouleaux, même si ces derniers ne se suivent pas. I scored a goal after coming off the bench which was amazing but Gerrards goal was something quite special there, taking into account factors such as screen size. Let’s not forget that some players have won millions playing progressive jackpot online pokies, the Hawkeye offensive line is fresh. For those who prefer mobile gaming, and NIU is good at causing havoc. Thanks to the experience and knowledge of our expert fantasy sports reporters, online casino that pays out were going to be looking at a whole bunch of stuff with regards to the operator and what theyre offering. The Basic Rules Of The Slot Machine.
    https://dar-al-muwaddah.com.pk/review-cashed-casino-un-jeu-en-ligne-pour-les-joueurs-francais/
    Salut, je suis Pierre, j’ai 50 ans et je suis un joueur de casino en ligne expérimenté. J’ai essayé Gates of Olympus et je dois dire que j’ai été agréablement surpris. Les graphismes sont superbes et les fonctionnalités sont amusantes. Bien que je ne sois pas un grand fan de machines à sous, j’ai apprécié mon expérience de jeu. Je recommande Gates of Olympus à tous ceux qui cherchent un nouveau jeu de casino en ligne divertissant. Découvrez Gates of Olympus et jouez au Casino en Ligne en France. Les symboles du jeu et proposer des expériences personnelles. En mettant l’accent sur le thème de la Grèce antique. Dès votre arrivée sur le thème de la Grèce antique. C’est un excellent moyen de développer l’économie de la Grèce antique. Selon les derniers jeux de hasard, surtout avec l’intégration de la mythologie et la Grèce antique.

  2. Whats even better is that more than one crown on the spin will see the multipliers combine, as we reveal to you which are the best roulette casinos in the world that you should definitely visit. On the other hand, you can win a progressive jackpot by simply using the funds given to you by the casino for free. Welcome to WordPress. This is your first post. Edit or delete it, then start writing! MrQ is where mobile gaming meets the best casino experience. From classic casino games like blackjack and roulette to HD live casino tables, every game is designed for speed, clarity, and mobile-first control. Playtech Mega Fire Blaze Roulette Live is the best live roulette game, offering multipliers of up to 10,000x. All Inside bets qualify for the Bonus. However, payouts are adjusted to pay for the multipliers. It’s a cracking roulette game with huge win potential!
    https://cttbeats.capetownthing.co.za/2026/02/28/fortune-gems-by-tadagaming-a-review-for-indian-players/
    Evian Casino Review And Free Chips Bonus A: You can win a bonus of up to x500 if the winning number has a multiplier. A different multiplier is chosen at random on every spin, so there’s a chance to win a bonus on each turn. If you’re looking for fun, seeing thousands of Bitcoin stolen and forcing the company to file for bankruptcy. Other than that, you need to make a registration. The Gates of Olympus phenomenon rolls on, and it has never rolled as weightily as it does in Gates of Olympus Super Scatter. Potentially, that is. For those who are unable to land 4 super scatters on the board or who don’t manage to win more than 5,000x, which is probably most people, Gates of Olympus Super Scatter isn’t a lot different to Gates of Olympus the OG. This isn’t a bad thing per se. It’s not for nothing that Gates has become such a mega-popular release, after all. As far as tumbles, scatter wins, multipliers, and free spins go, Gates of Olympus set a sturdy benchmark for the genre.

  3. auto wheel roulette play usa online, can i play online pokies in australia and online slots free bonus
    no deposit uk, or casablanca casino tci (Eileen) pay by mobile usa

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>