Grails scaffolding – improved list page

Date 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

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • TailRank
  • YahooMyWeb
  • del.icio.us
  • DZone
  • Facebook
  • Reddit
  • StumbleUpon
  • Digg
  • Simpy
  • Technorati

2 Responses to “Grails scaffolding – improved list page”

  1. Reiner Saddey’s Place » Grails: Links from my first week with Grails said:

    [...] Grails scaffolding – improved list page [...]

  2. Søren Berg Glasius said:

    Hi Michael,

    This is a very nice way to do it. I’m currently collecting ways to improve my default scaffolding, and have found this for create/update

    /Søren

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">