views:

46

answers:

1

I'm newbie to grails and I've tried to use the grails pagination Tag found here link text
and when i tried to use it like he says like the this Controller :

 def pageslist = {
 [pages: Page.list(params)]
}

view

 < g:paginate next="Forward" prev="Back" maxsteps="5" controller="story" action="pageslist" total="${story.pages.count()}" />

it gives me nothing at all and the debugger never enter the controller method.. what is the problem and is there any other way for paginating in server side way

A: 

Try:

<g:paginate next="Forward" prev="Back" maxsteps="5" controller="story" 
            action="pageslist" total="${pages.count()}" />

Because you've returned a map [pages: Page.list(params)] as the model from your controller, you will be able to access the variable pages from your view.

Edit:

You need to get the total count of Pages that you want to paginate through. Either use total="${Page.count()}" or add another variable to your model.

see the documentation on the Paginate tag for more.

Colin Harrington
i will try it sir and will confirm you asap :) can't tell you how much i appreciate it
Mohamed Emad Hegab
You shouldn't use `pages.count()` for the total attribute, since `pages` is the already paginated list of pages (i.e. only the pages that are displayed in the current pagination step). The `total` attribute, however, expects the *total* number of items (for it to be able to determine the total number of pagination steps).
Daniel Rinser
it didn't work it said that it can't get count on null object.. it means pages.. and when i make null safe pages?.count() it gives me another error message that Tag [paginate] is missing required attribute [total]that means that the problem persist that the paginate don't call the pageslist function at all :(
Mohamed Emad Hegab
Mohamed Emad Hegab
Daniel you are right, he needs to add another variable. I just wanted to quickly point out that story.pages.count() doesn't work.
Colin Harrington
so what is the solution do you think in my case..you can access my project through githunhttp://github.com/emadhegab/egypths
Mohamed Emad Hegab