The Grails Framework
Table of contents
1
Introduction
2
Getting Started
3
Upgrading from the previous versions
4
Configuration
5
The Command Line
6
Object Relational Mapping (GORM)
7
The Web Layer
8
Traits
9
REST
10
Asynchronous Programming
11
Validation
12
The Service Layer
13
Static Type Checking And Compilation
14
Testing
15
Internationalization
16
Security
17
Plugins
18
Grails and Spring
19
Scaffolding
20
Deployment
21
Contributing to Grails
Quick Reference
(
Quick Reference
)
The Grails Framework
Authors:
The Grails Team
Version:
6.1.0
Table of Contents
1
Introduction
1.1
What's new in Grails 6?
1.1.1
Updated Dependencies
2
Getting Started
2.1
Installation Requirements
2.2
Downloading and Installing
2.3
Creating an Application
2.4
Creating a Simple Web Application with Grails
2.5
Using Interactive Mode
2.6
Getting Set Up in an IDE
2.7
Grails Directory Structure and Convention over Configuration
2.8
Running and Debugging an Application
2.9
Testing an Application
2.10
Deploying an Application
2.11
Supported Java EE Containers
2.12
Creating Artefacts
2.13
Generating an Application
3
Upgrading from the previous versions
3.1
Upgrading from Grails 5 to Grails 6
3.2
Upgrading from Grails 4 to Grails 5
3.3
Upgrading from Grails 3.3.x to Grails 4
4
Configuration
4.1
Basic Configuration
4.1.1
Options for the YML format Config
4.1.2
Built in options
4.1.3
Logging
4.1.3.1
Logger Names
4.1.3.2
Masking Request Parameters From Stacktrace Logs
4.1.3.3
External Configuration File
4.1.4
GORM
4.1.5
Configuring an HTTP proxy
4.2
The Application Class
4.2.1
Executing the Application Class
4.2.2
Customizing the Application Class
4.2.3
The Application LifeCycle
4.3
Environments
4.4
The DataSource
4.4.1
DataSources and Environments
4.4.2
Automatic Database Migration
4.4.3
Transaction-aware DataSource Proxy
4.4.4
Database Console
4.4.5
Multiple Datasources
4.5
Versioning
4.6
Dependency Resolution
5
The Command Line
5.1
Interactive Mode
5.2
Creating Custom Commands
5.3
Creating a Grails Project
6
Object Relational Mapping (GORM)
6.1
Quick Start Guide
6.1.1
Basic CRUD
6.2
Further Reading on GORM
7
The Web Layer
7.1
Controllers
7.1.1
Understanding Controllers and Actions
7.1.2
Controllers and Scopes
7.1.3
Models and Views
7.1.4
Redirects and Chaining
7.1.5
Data Binding
7.1.6
Responding with JSON
7.1.7
More on JSONBuilder
7.1.8
Responding with XML
7.1.9
Uploading Files
7.1.10
Command Objects
7.1.11
Handling Duplicate Form Submissions
7.1.12
Simple Type Converters
7.1.13
Declarative Controller Exception Handling
7.2
Groovy Server Pages
7.3
URL Mappings
7.3.1
Mapping to Controllers and Actions
7.3.2
Mapping to REST resources
7.3.3
Redirects In URL Mappings
7.3.4
Embedded Variables
7.3.5
Mapping to Views
7.3.6
Mapping to Response Codes
7.3.7
Mapping to HTTP methods
7.3.8
Mapping Wildcards
7.3.9
Automatic Link Re-Writing
7.3.10
Applying Constraints
7.3.11
Named URL Mappings
7.3.12
Customizing URL Formats
7.3.13
Namespaced Controllers
7.4
CORS
7.5
Interceptors
7.5.1
Defining Interceptors
7.5.2
Matching Requests with Interceptors
7.5.3
Ordering Interceptor Execution
7.6
Content Negotiation
8
Traits
8.1
Traits Provided by Grails
8.1.1
WebAttributes Trait Example
9
REST
9.1
Domain classes as REST resources
9.2
Mapping to REST resources
9.3
Linking to REST resources from GSP pages
9.4
Versioning REST resources
9.5
Implementing REST controllers
9.5.1
Extending the RestfulController super class
9.5.2
Implementing REST Controllers Step by Step
9.5.3
Generating a REST controller using scaffolding
9.6
Calling REST Services with HttpClient
9.7
The REST Profile
9.8
JSON Views
9.8.1
Getting Started
9.8.2
Creating JSON Views
9.8.3
JSON View Templates
9.8.4
Rendering Domain Classes with JSON Views
9.8.5
JSON Views by Convention
9.9
Customizing Response Rendering
9.9.1
Customizing the Default Renderers
9.9.2
Implementing a Custom Renderer
9.9.3
Using GSP to Customize Rendering
9.10
Hypermedia as the Engine of Application State
9.10.1
HAL Support
9.10.2
Atom Support
9.10.3
Vnd.Error Support
9.11
Customizing Binding of Resources
9.12
RSS and Atom
10
Asynchronous Programming
11
Validation
11.1
Declaring Constraints
11.2
Validating Constraints
11.3
Sharing Constraints Between Classes
11.4
Validation on the Client
11.5
Validation and Internationalization
11.6
Applying Validation to Other Classes
12
The Service Layer
12.1
Declarative Transactions
12.1.1
Transactions and Multi-DataSources
12.1.2
Transactions Rollback and the Session
12.2
Scoped Services
12.3
Dependency Injection and Services
13
Static Type Checking And Compilation
13.1
The GrailsCompileStatic Annotation
13.2
The GrailsTypeChecked Annotation
14
Testing
14.1
Unit Testing
14.2
Integration Testing
14.3
Functional Testing
15
Internationalization
15.1
Understanding Message Bundles
15.2
Changing Locales
15.3
Reading Messages
15.4
Scaffolding and i18n
16
Security
16.1
Securing Against Attacks
16.2
Cross Site Scripting (XSS) Prevention
16.3
Encoding and Decoding Objects
16.4
Authentication
16.5
Security Plugins
16.5.1
Spring Security
17
Plugins
17.1
Creating and Installing Plugins
17.2
Plugin Repositories
17.3
Providing Basic Artefacts
17.4
Evaluating Conventions
17.5
Hooking into Runtime Configuration
17.6
Adding Methods at Compile Time
17.7
Adding Dynamic Methods at Runtime
17.8
Participating in Auto Reload Events
17.9
Understanding Plugin Load Order
17.10
The Artefact API
17.10.1
Asking About Available Artefacts
17.10.2
Adding Your Own Artefact Types
18
Grails and Spring
18.1
Configuring Additional Beans
18.2
Runtime Spring with the Beans DSL
18.3
The BeanBuilder DSL Explained
18.4
Property Placeholder Configuration
18.5
Property Override Configuration
18.6
Spring Boot Actuators
19
Scaffolding
20
Deployment
20.1
Standalone
20.2
Container Deployment (e.g. Tomcat)
20.3
Deployment Configuration Tasks
21
Contributing to Grails
21.1
Report Issues in Github's issue tracker
21.2
Build From Source and Run Tests
21.3
Submit Patches to Grails Core
21.4
Submit Patches to Grails Documentation
Quick Reference
(
hide
)
Command Line
Usage
assemble
bootRun
create-app
create-controller
create-domain-class
create-plugin
create-restapi
create-service
create-taglib
create-web-plugin
generate-all
generate-controller
generate-views
help
install-templates
list-features
schema-export
Constraints
Usage
attributes
bindable
blank
creditCard
email
inList
matches
max
maxSize
min
minSize
notEqual
nullable
range
scale
size
unique
url
validator
widget
Controllers
Usage
actionName
allowedMethods
bindData
chain
controllerName
defaultAction
errors
flash
forward
grailsApplication
hasErrors
header
namespace
params
redirect
render
request
respond
response
responseFormats
scope
servletContext
session
withForm
withFormat
Database Mapping
Usage
autoImport
autoTimestamp
batchSize
cache
cascade
column
comment
discriminator
dynamicInsert
dynamicUpdate
fetch
id
ignoreNotFound
indexColumn
insertable
joinTable
lazy
order
sort
table
type
updateable
version
Domain Classes
Usage
addTo
attach
belongsTo
clearErrors
constraints
count
countBy
createCriteria
delete
discard
embedded
errors
executeQuery
executeUpdate
exists
fetchMode
find
findAll
findAllBy
findAllWhere
findBy
findOrCreateBy
findOrCreateWhere
findOrSaveBy
findOrSaveWhere
findWhere
first
get
getAll
getDirtyPropertyNames
getPersistentValue
hasErrors
hasMany
hasOne
ident
instanceOf
isAttached
isDirty
last
list
listOrderBy
load
lock
mapWith
mappedBy
mapping
merge
namedQueries
properties
read
refresh
removeFrom
save
transients
validate
where
whereAny
withCriteria
withNewSession
withSession
withTransaction
Plug-ins
Usage
URL mappings
codecs
controllers
core
dataSource
domainClasses
hibernate
i18n
logging
scaffolding
services
servlets
Services
Usage
scope
Servlet API
request
response
servletContext
session