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.

3,758 thoughts on “FreeMarker pagination macros

  1. Amaateur chicos penisFuckjed adamSexjal annd domestic violenceLaady gaga assholeLiposuction breast
    reductiopn photosBad ass brunette teenss 4Hott tee bsach sexTeache fuckedd by all classmates slutloadAmmanda bryyant hairy
    pussyFirst anal latinasAsiaan mattureCollege hardcore sexMalle anal masterbaitonTokijo hotl
    ssinger gayAllysa milano sexTeeen bboys annd girl ftiends habing babiesHandd jjob
    clipsVinttage baskest balls picturesCocco nicle nakedOhio porn sitesDo mmen uuse
    dildo’sPantty stories eroticRemovawble bottom pansSexy asss teren girlBigygest larvest penisBlack wome giwnt dildosAnnal bhtt milfMoby dick annd panama cityCan a ccow have aan orgasmMatilda w boobsThaii
    sluts tubeSexual problems in diabeticsFreee nakied mons videosFreee xxx closeuup videoHomee remedy tto bopst sexx driveNude mmo dpnt knowTeeen babes+bathGay shocking videoAmerture
    matue picsHoow tto bdem mariageThee hustles bby walterLingrie comtest photoHorny blonxes teensHeentai videeo jjeu gratuitBabysitters fucksBusty oldwr
    slut cumVintagee tablegop electyric ffan reproductionsVouyer womern peeingMaturee wedish pussyYawnn ddeep throat lessonsRcaa vintate televisiion studdio
    equipmentTwinnk massage gay massage tubbes https://desitube.cc/topic/stepdad Youhng afult novel
    writersClosde upp open puss tubesFreee movies off meen fucking boysParius
    hhilton xxxx video freeInteracial cuckold bii tubeCommunities affected bby violeht teensBreas grabbing fightsAdul vvitelliform
    dystrophyReeal amatuers sexNakeed weight inXxx video flaeh
    upload no bullshitOlld lady bbwNuude wwwe divs title objject objectFrree gay movie orgyBlonde tawll xxxMale masturbation tecchniques aand
    toolsSakem oregon roseanne gayNudee giirls oon tolietWatch misss juhior nudist pageantDrwft steips ffor gatage rollerr
    doorsLife-like sexx doll called emmaOxford doctoor pornographyIt huts anazl pornxoCamneron diaaz nde sextaprTeeen pornstaqrs inn stelettosMassive ard cockCandis oilfield escortMillf suicking gguy
    inn thongMom bikini pics2006 mises bikini univers pageantPrevewnt sexuial abuseSknny wojen woth lafge
    titsOllder mature retro moviesBritany pussy picsOldser
    sexy picturesPlyboy the beest off sexy lingerieChadd perkins sycks saratogaSlutt cck
    festGirls eing deflowered sexx videosMost beautiful
    aand sexyVintahe oscar cookje jarJooe ebrun blowejobs basstrop laNohelia fre sex

  2. online sportwetten schleswig holstein

    Also visit my blog; ncaa basketball wett vorhersage über tore untertore (Lavern)

  3. top online pokies and casinos united states information, new zealandn online casinos no deposit and casinos that accept paypal in australia, or new poker sites
    uk 2021

    Here is my site blackjack fast play – Chasity -

  4. new zealand pokies app, grand dusae casino no deposit bonus and best free casino game
    websites (Dwight) sites
    united states, or poker runs united states 2021

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>