I am learning grails and I have a problem.
I have 2 classes, say:
class Book {
String name
String description
static belongsTo = Category
Category category
static constraints = {
name(nullable:false, blank:false)
description(nullable:true, maxSize:5000)
}
class Category {
String name
static hasMany = [books:Book]
Set books
static constraints = {
name(nullable:false, blank:false)
}
String toString(){
this.name
}
}
When I create a book, I want to see a drop-down list with all category names. If I do not choose a category, I cannot create this book. If there are no categories in the database, than I could not create the book until I create and select a category.
Is it possible for these functions to be generated (using grails generate-all) from domain classes if I have the correct constraints and fields? If so, how?
source
share