20 Scaffolding - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.0.1
20 Scaffolding
Scaffolding lets you generate some basic CRUD interfaces for a domain class, including:- The necessary views
- Controller actions for create/read/update/delete (CRUD) operations
build.gradle
.dependencies { // ... runtime "org.grails.plugins:scaffolding" // ... }
Customizing the Generated Views
The views adapt to Validation constraints. For example you can change the order that fields appear in the views simply by re-ordering the constraints in the builder:def constraints = { title() releaseDate() }
inList
constraint:def constraints = { title() category(inList: ["Fiction", "Non-fiction", "Biography"]) releaseDate() }
range
constraint on a number:def constraints = { age(range:18..65) }
def constraints = { name(size:0..30) }
Static Scaffolding
Grails also supports "static" scaffolding.The above scaffolding features are useful but in real world situations it's likely that you will want to customize the logic and views. Grails lets you generate a controller and the views used to create the above interface from the command line. To generate a controller type:grails generate-controller Book
grails generate-views Book
grails generate-all Book
grails generate-all com.bookstore.Book