Generating Scaffolding Code

Grails gives us an easy way to generate the code that does what the dynamic scaffolding has been doing for us. We won’t see any changes to the application, but we will have the code necessary to make changes. To get started, we will use the grails generate-all script.

The generate-all script can be called in a few different ways. If you call it with no arguments, you will be prompted for a name. (By convention, this would be a domain class name.) For the more argumentative types, you can call generate-all with a name as the argument. Both of these approaches generate a controller, four .gsp view files, and a template, which is also a .gsp file. (We’ll have a detailed discussion on templates in Of Templates and ...

Get Grails 2: A Quick-Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.