Professional Documents
Culture Documents
Grails - CRUD
Grails - CRUD
What to Notice?
Domain object is mapped to database table Properties are mapped to table columns Constraints are used to validate input (minSize, maxSize, inList, blank,) Error messages due the constraints are configurable according to convention Domain class is by convention created in directory domain
What is Controller?
Controller handle requests and creates responses Controller is request based Each request is mapped with closure If not specified differently, closure in controller is mapped to view (gsp)
Book Controller
What to Notice?
Generated closures are for CRUD operations Use of dynamic methods on domain objects (save, hasErrors, get, list) Rendering and redirecting Name of the controller by convention is: <domain_class_name>Controller Controller is by convention created in directory controllers
Book Views
What to Notice?
Generated views are for CRUD operations Accessing to model data with ${..} construct Views are by convention generated in the directory views/<domain_class_name> Actually functionality and layout of page is good out of the box and for internal application can be reused without modifications
Make changes to views if necessary (for simple CRUD applications you can leave it as is)