Pagination in Grails

Viewed 2425

I want to add some pagination stuff to my grails app. I have the list action and in it I did this:

if(!params.max){
params.max = 3
}
    def query = Profile.where {
        userType == "F"
    }
    def freelancers = query.list(sort:"firstName", max:params.max)
    if(freelancers) {
        def freelancersCount = query.count()
        return[freelancer:freelancers, fCount:freelancersCount]
    } else {
        response.sendError(404)
    }

in gsp I wrote this:

<div id="paginate">
    <g:paginate controller="freelancers" action="list" total="${fCount}"/>
</div>

everything is ok, a have a 5 objects in my db and i can see only 3 when open a gsp page in browser, but when I click on the Next to open other 2 object, I see the same 3 ones. what is wrong and what I must to do?

2 Answers
Related