I want to exclude domain field from data binding Is it possible to mark class field by an annotation?
For example domain:
class Article {
String text
.....
Author author
}
in code I have to write bindData(article, params, [exclude: ['author']]) for cheating prevention
But much easier simple to annotate Author author. But I didn't find how.
Since Grails 2.1.0 you can use the bindable
constraint to indicate that a property should not be automatically assigned during data binding.
class Article {
String text
...
Author author
static constraints = {
author bindable: false
}
}
Now calling bindData(article, params)
will automatically exclude the article's author
property.