tags:

views:

40

answers:

2

In Spring Roo if I don't want a specific method to automatically be generated I can remove an annotation. Is there a way to do this in Grails? For example I would like the list and create methods of a controller to automatically be updated with any changes in the domain model when I do a generate-all, but would like to use custom code for the show method that does not get changed unless I manually edit it.

+1  A: 

If you provide an action in a dynamic scaffolding controller then Grails won't create that action at runtime (but it will create all the others). So if you don't want the show action to be updated do this

class SomeDomainObjectController {
  def scaffold = SomeDomainObject

  def show = {
    // Your logic for this action goes here
  }
}
Don
A: 

Run 'grails install-templates' and it will copy the template scripts that are used to generate the controller, GSPs, etc. Edit those to have the methods that you want.

This isn't as flexible as Roo in that it's global and not available per-instance but if you want the same structure for all controllers then it'll work for you.

Burt Beckwith