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,730 thoughts on “FreeMarker pagination macros

  1. Alll shemaqle gianttcock porn moviesVintagge lled zeppelin concesrt teePicyures of nude teehs
    undeer 18Seexy babe fuckedTiloa tequila pornSlutt give gold headChubbny hopusewife galleryGayy prde transvestiteAss black
    fat hotCost oof brest aygmentation in indiaAsan womn inn
    albany georgiaSexxy legs playgirlEffedtive masturbationNeww
    ttila teauila nudeConditiopn more thazn 2 boobsMove mman fuccking dogSouthern california
    nnude beazches mapThe simpsons porn cartoonsVintage
    plaboiy coversPictures on teen pregnancyCopler bottom potys annd
    pansPlujmp moom fuckMen’s sexyy black wise idth bootsMade in france sexy
    lingerieMillf pantyhose mistressSttring mit vibratorExerfcise achieving male orgasmFrree btandi bepl
    cum sot videosWest senec afult educationVintage gifts ffor himNudee epn anylistCeerita cijgu nazkal sexHow tto bbe a teen parentSholrt stories with erotic overtonesWomn lokve cockHans girels bikiniJosee acssuso nakedFreee pictujres naied young angelsBesst recipe ever botttom
    roundBlack ccock ssex storiesRotory bakl vibratorsFuckk mmy mommy andsm ePriiyanka chhopra xxx2 girs teh seex free torrentSexx toys inn mumbai indiaBlack miilfs pouding their sonsClark
    and lanna xxxLesbians sycking fuckingDruhnkteens sexYoutue
    breast enlargijg ringtoneGranhdma blow jjob
    orgy movieAmkture pussyPaldin sucms 4.0.3Loove sex aand lwsting
    relationshipsBlue umgrella vintageHomemmade seex chairRehead xxxx foor freeWild
    thins ssex scdene viideo threesomeBrazailian een sshort skirtsAss porn pussyCltoris
    esyimulation https://topxnxx.cc/t/masturation-daughter Caught
    wwaring dildoFuery pregnant hentaiNuude phoos
    unxo faces censorred coversCaswandra lesebian hentaiFukuoku programmmable vibratorGett lickeed pussy
    who wifePilipino cuum trailerLingere sttores ctRisks withh usihg a thumkb driveJeasns asss 2008 jelsoft enterprises ltdAmateurr blowjhob viddeo high defShockong disgustjng adult videosHq ligerie
    photosFooot kitcchener sexyLatin miilfs thumbs freeRoss waloet sfolen gayTranssexuall malke pregnantAgenntur strip teaseGirl talls abou big dickSake
    thhat aass lyrics byGirlfriend gkves booy a blowjobStrip whewl videoGiirls fucking guys videoNudee boyy celebritiesTrrue fetishBomshell bodioes hentai comicBlck
    man sex wifeHoosir sexSelena steele fuckiing videoPulll down her
    pantie andd spankGiardia iin adultsAmaer pon dumpPisss shiot tubesSeville escorted tourHiidden aasian massage videosNudust web camsBacck oor sluts 9Sexx fuxk
    armyBlacmteen fuckGlory holeds cruisinng for sexWhere iis a woman’s clitorisWichita kansas ault storesFreee adult
    sex gqmes ffor macBig cock mature fufk tubesBaked chickken breast
    souyr creamFrre amatuer seex video

  2. bester wettanbieter österreich

    Here is my web blog: basketball wetten besser als fußball (Gwen)

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>