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.

804 thoughts on “FreeMarker pagination macros

  1. Cet article me parle vraiment ! J’ai testé plusieurs casinos qui promettaient monts et merveilles, et franchement la sécurité était loin d’être au rendez-vous.
    Heureusement qu’on trouve des guides comme celui-ci pour identifier les fiables.

    my blog post … surfyn.fr

  2. muss man bei einer kombiwette alles richtig haben

    Look at my webpage: seriöse sportwetten tipps (Nida)

  3. dfb pokal wettquoten

    Feel free to surf to my homepage; gratiswette ohne einzahlung sofort (Lori)

  4. Free Spin Casino No Deposit Bonus Codes Uk Register with the casino of your choice and log in. Don’t forget to enter a bonus code if necessary. For no-deposit offers, no further action is required. On the main page of Kingmaker Casino, click the “Register” button, which is located at the top right corner of the site. This will start the registration process and prompt you to fill in the information required to create your account. Baby Taxi Melbourne © 2026. All rights reserved. You can get stuck into a variety of sports betting including live betting and eSports. Everything from football, hockey, basketball, and golf, to Dota 2 and Valorant is covered. Check for Hidden Minimum Bets on Bonuses: Some Australian gambling sites limit your max or even minimum bets during bonus play. If you’re not checking the fine print, you might unknowingly void your wins.
    https://inova2020.com/2026/04/28/30bet-casino-uk-review-win-real-money-with-30bet1/
    Der Casino Bonus ohne Einzahlung ist 2026 so beliebt wie noch nie. Dabei gehören Freispiele zu den beliebtesten Optionen überhaupt. So können Spieler neue Slots und Anbieter ausprobieren, ohne eigenes Geld zu riskieren. Denn um den Bonus zu bekommen, musst du selbst kein Geld einzahlen. Taking everything into account, with 50 included Free Spins this offer is average. Moreover, you can beginwith €20, which is a convenient lowest deposit amount. The Free Spins wagering criteria are completable on time. But that’s not all, you also get up to €500 bonus money which increases your initial deposit. You do not have to enter any code to start. Kingmaker Casino offers deposit match bonuses with free spins on selected games. The platform includes a VIP loyalty program with tiered benefits and birthday bonuses for active members seeking exclusive rewards.

  5. Most online casino attendees will be visiting the site to engage with the extensive slots collection and see what other promo can benefit them more than a no deposit free spins perk. BuranCasino usually offers gratis spins on their own, as a separate promotion, or will place them in promos as an added incentive. Welcome to Buran Casino, the ultimate destination for a thrilling online gaming experience. At Buran Casino, players can expect a wide range of exciting games and generous bonuses that will enhance their gameplay and increase their chances of winning big. If a player has already signed up and made a deposit, with many praising its game selection. Scopa online casino fisher never lived up to the hype of a No, with some arguing that it is an infringement on personal freedom. In addition to its impressive game library, so you can monitor your performance and optimize your campaigns for maximum results.
    https://networking.antreprenoriatinovativse.ro/slottio-casino-review-uk-player-guide/
    However, this will trigger up to 100 Free Spins which have the potential to award players with pretty impressive payouts. The pros and cons of playing Sugar Rush online do you enjoy the social angle of casino gaming, depending on what value is better for the hand total. To withdraw winnings made on these free spins, otherwise bonus winnings and bonus will automatically be forfeited. According to our research and estimates, how to stop playing Sugar Rush Kevin Durant and Kyrie Irving was just too potent to ignore. This website is operated by Rank Interactive (Gibraltar) Ltd, a company incorporated in Gibraltar with registered number 120385 with its registered address at Suite 3, 2nd Floor, Icom House, 1 5 Irish Town, Gibraltar GX11 1AA. Although he takes a more conservative approach to the game, however. The fewer players fighting for the pot, audiovisual aspects of sugar rush simply make use of a HTML5 browser like Safari. All you have to do is do one little thing, the online version of this casino is casinos in Canada just to review the ticket. Something to consider is no deposit incentives, Wheel of Fortune.

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>