Environment
set $GRAILS_HOME=path to grails
set $JAVA_HOME=path to java
set $PATH=include $JAVA_HOME/bin and $GRAILS_HOME/bin
Init
grails create-app App1
Run
grails run-app
Create Domain
grails create-domain-class d1
path: grails-app/domain/d1.groovy
Data Constraints
class d1 {
String name
String address
Date dob
d2 linkedData
static constraints = {
// order of fields in constraints are used in scaffolding
name(size:1..48, unique:false)
address(maxSize:128,blank:true)
dob(blank:true)
// linkedData of custom type nullable as in the case linked data doesn't exist,
// then d1 can't be created
linkedData(nullable:true)
}
}
Create controller
grails create-controller c1
path: grails-app/controller/c1.groovy
Scaffolding
class c1Controller {
def scaffold = d1
}
Testing
grails test-app -unit
grails test-app -integration
set $GRAILS_HOME=path to grails
set $JAVA_HOME=path to java
set $PATH=include $JAVA_HOME/bin and $GRAILS_HOME/bin
Init
grails create-app App1
Run
grails run-app
Create Domain
grails create-domain-class d1
path: grails-app/domain/d1.groovy
Data Constraints
class d1 {
String name
String address
Date dob
d2 linkedData
static constraints = {
// order of fields in constraints are used in scaffolding
name(size:1..48, unique:false)
address(maxSize:128,blank:true)
dob(blank:true)
// linkedData of custom type nullable as in the case linked data doesn't exist,
// then d1 can't be created
linkedData(nullable:true)
}
}
Create controller
grails create-controller c1
path: grails-app/controller/c1.groovy
Scaffolding
class c1Controller {
def scaffold = d1
}
Testing
grails test-app -unit
grails test-app -integration