开发者

Maintaining page number across requests

I have a button o开发者_JAVA百科n the client side and when I press, I execute some action on the server and then I call the list method again. Everything works fine but let's say I'm on page 3 and click an item, when the page refreshes it takes me to page 1. I don't know which page I'm on. Is there any way to maintain the page number?


You need to pass the offset and max parameters through your request. You can pass the current params with the link tag, if you're using it:

<g:link action="myAction" params="${[offset: params.offset, max: params.max]}"/>

If you're not using <g:link>, you can just make them query parameters in your href:

<a href="/path/to/action?max=${params.max}&offset=${params.offset}">Link</a>

These params need to make it into the .list() method in your controller (e.g. .list(params)).

As long as the params are set in the action that renders the resulting view, the <g:paginate> tag will pick them up and render the pagination links correctly.


you can pass params as

<g:link action="myAction" params="${[offset: params.offset, max: params.max]}"/>

and

returns params back from controller where you redirect your page as params

e.g redirect (action: 'myAction', params: [max: params.max, offset: params.offset])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜