简体   繁体   中英

grails pagination tag don't access method

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

You should use as Colin sugested last, ${Page.count()} and import Page into your gsp:

<% import pa.ck.age.Page %>

or you can add another param to the model returned to the view:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM