Marcel Overdijk has written a couple of entries regarding a common problem faced when paginated views are involved and how he found a solution with Grails.

With the default Grails scaffolding each time you navigate away from the 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.

His first attempt solves the problem right away at the source, in other words, at the controller’s action being invoked. The next iteration refactors the remembering strategy into its own method, and it includes a slicker syntax thanks to the Elvis operator. The last iteration is one step further into customization, in Marcel’s words

In my Grails project I’ve added a ‘restoreState’ method dynamically using the ExpandoMetaClass to all Controller classes. The method is simply added in BootStrap.groovy

Here are the links to each version and their code

The last iteration may as well be packaged in its own plugin don’t you think?

Tags: , ,



One Comment to “Remembering state of a Grails list page (Marcel Overdijk)”

  1. Ronna Davis | November 12th, 2008 at 8:57 pm

    38qu2jmqrrytzkxs

Leave a Comment