Grails scaffolding - improved list page
May 20, 2008
The default Grails scaffolding is useful, but I’ve been finding that I don’t care for the ‘list’ view that’s generated (dynamically or statically). Why not? Well, because it just shows a numeric ID which you need to click on to ’show’ the field, and then you can ‘delete’ or ‘edit’ the entry from the ’show’ screen. This is very inefficient in my view, so I’ve been playing with a new version.
This new version will replace the ‘id’ column with a column called ‘Action’, and this column will contain 3 links - ‘view’ ‘edit’ and ‘delete’. The delete functionality has a javascript confirm ‘are you sure?’ attached to it to require confirmation before deleting something. This is rather rudimentary - there’s no i18n in this, for example. ‘view’, ‘edit’, ‘delete’, ‘are you sure?’ and ‘action’ would all be candidates for translation. However, this will get you up and running.
To use this, run ‘grails install-templates’ from your grails base directory, then copy the following file in to src/templates/scaffolding/list.gsp. Feel free to suggest changes back. This is planned to be the default ‘list’ view for GrailsKit, the starter kit project I’m working on.
Download the new list.gsp scaffold file
Did you like this post? Buy me a hot chocolate!
Posted in



