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.

6,455 thoughts on “FreeMarker pagination macros

  1. Helo there, I folund your siite by wway oof Google whilst lookin foor a related subject,
    youir website got here up, it appears good. I’ve bookmarked iit iin mmy oogle bookmarks.

    Hi there, simpy becake alert tto yoyr blog thdu Google, aand loccated that it’s reslly informative.
    I am gonna bee csreful forr brussels. I’ll appreciate when youu continue this inn future.
    A lot off folkjs wiill probaably bee benefited oout oof you writing.

    Cheers! xnxx

  2. uk free spins 2021, australian currency poker chips and free spins bonus codes uk, or
    best canada poker sites

    Feel free to surf to my web page … roulette whatsapp group, Billy,

  3. best online slot usa, best bingo at home hacks (Romaine) sites usa 2021 and online gambling
    australia legislation, or free 50 pokies canada

  4. casinos sin depósito permitido en españa con tiradas gratis

    Take a look at my web blog – magna casino albacete (Aidan)

  5. Alight Motion is one of the few pro-motion graphics apps that brings you quality animations and visual effects. It enables you to tweak multiple layers of graphics and make your videos perfect. There is a range of features from color corrections to frame animations and editing tools that you can use on your videos.  Alight Motion Social Media Apps Guide: How to Create Viral Content for WhatsApp Facebook Instagram Pinterest Telegram Threads & Twitter 6.2M Reviews Latest Version 100M Downloads To create eye-catching and trendy content for your WhatsApp Facebook or Instagram Alight Motion Mod APK is one of the best apps that fulfill this purpose. From motion graphics… Quick Win: Keep frequently used custom fonts and LUTs in the AlightMotion Font and AlightMotion LUT folders for instant access https://doodleordie.com/profile/penszurrutha1976 Connect with us A: No the demo version is big bass bonanza megaways for practice purposes only. Winnings in the demo do not translate to real money. Released in April 2025 Big Bass Bonanza 1000 sees Big Bass Bonanza meet the 1000 series. Very similar other games in the Big Bass slots series it’s played on 5 reels and 10 paylines from 10p a spin. In the free spins Fisherman Wilds collect fish money symbols which are worth up to 1000 x your total bet. Every 4th Fisherman Wild gives you more free spins and applies a win multiplier up to 10x to collected fish money symbols. With a 96.51 RTP rate this game offers 20000 x bet max wins joint top with Big Bass Hold & Spinner Megaways.  Pragmatic Play giving this series the 1000 upgrade brings bigger potential wins. Overall the game retains the classic mechanics of the original but it massively increases the max win to 20000x. This is done by using higher-value Fish symbols and offering a Super Free Spins mode that increases probability of bigger fish landing. If you enjoy playing Big Bass slots then this game will definitely float your boat. Moreover Pragmatic are running a £600000 mega tournament to celebrate the launch of the game.

  6. new zealandn online tutti i casino online italiani (Annie) minimum deposit $10, canadian star casino kansas city and usa slots no deposit free spins, or free casino money
    united states

  7. To animate a photo with AI means using artificial intelligence to transform still images into moving visuals. This process involves applying motion effects to facial features body parts or background elements making a static picture appear alive. An AI animated image can simulate a wide range of movements such as: Transform your photos into spectacular animations & Stand out from the crowd on social media. Bring your images to life like never before To produce high-quality videos with Fotor’s video converter designed to transform your static images into captivating video content whether for personal projects social media marketing or educational purposes you don’t the need for complex video making software or any professional video editing skills. It’s free fast and easy. We understand your concern regarding privacy and data collection. We take your privacy seriously and comply with all relevant laws. The app collects certain data for improving performance and user experience but we respect your privacy and offer settings to control what’s shared. If you have any concerns or need further clarification please contact us at hireviveapp.net. We’re here to assist you and value your feedback. http://forum.dmec.vn/index.php?members/freemdersvodi1975.245363/ Loved this story and want to support me as a writer? You can do so through PayPal. I’m now exploring Substack so if you want to support me as a writer subscribe to my Substack. It’s 6 a month giving you unlimited access to content like this and also exclusive content. It’s important to know your story before you begin to animate especially if you plan to upload your video to a series. Storyboarding will help you to think through your video’s script and make sure that your video will have a clear beginning middle and end. As the popularity of animated content continues to soar people are always looking for creative ways to convert their videos to cartoon-like animations. This is where video cartoonizer apps come in handy. In this ultimate guide we will explore everything you need to know about videos or photos to cartoon conversion including the benefits how it works and the top video editing apps available on the market today.

  8. mid united states casinos, casino jack milwaukee and
    free spins no deposit 2021 usa, or dragon link make money playing video games online (Ingrid) pokies canada

  9. all united statesn bingo, best online pokies in united kingdom and best united kingdom casino, or best online royal casino no deposit bonus codes 2022 (Joanne) sites for real money canada

  10. new online usa casino, best 10 pound deposit bonus (Donte) bonus uk and best casino sites
    in canada, or are there pokies in new united states

  11. playtech casinos usa, online casino uk top 10 and what is the most trusted online casino in united states,
    or real money online doubledown casino more free chips [Wilda] united
    states reviews

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>