Plugins You can find out about all the publicly available Grails plugins.

RestoreState Plugin

  • Authors: Marcel Overdijk
1 vote
compile "org.grails.plugins:restore-state:1.1"




RestoreState Plugin

This plugin provides convenient methods to controller classes for remembering state. With the default Grails scaffolding each time you navigate away from a list page (e.g. going to the show page) the state of the list is lost when you return. This can be annoying when you paged to a certain page within the list. A typical use case for this plugin is restoring the pagination state (like offset and sorting) of list pages.


To install the restore state plugin type this command from your project's root folder:

grails install-plugin restore-state


To use the restore state plugin to restore the state of list pages change your controller as below:

def list = {
    restoreState([max: 10, offset: 0, sort: "title", order: "asc"])
    [ bookList: Book.list( params ) ]

That's it. Your list page now remebers it's state.

How it works

When calling the restoreList method the passed in stateParams map will be stored in both the request params and the session. The following logic is used to determine the actual values stored: (1) use params (2) or use session (3) otherwise use default value

This example will clarify it:

restoreState([max: 10])

(1) if request params object contains "max" param, store it in the session (2) if session contains "max" param, store in the request params object (3) otherwise, store the default value (in this case 10) in both the request params obect and the session.

Plugin version history

1.1 (March 11, 2008)

  • Upgrade to Grails 1.1
  • Minor improvements

1.0 (November 21, 2008)

  • Initial release