Can I do something like this inside controller action
def update(){
if(certain validation fails )
//flash message to be visible
[domainInstance:originalDomainInstance,flash.message : "message(code:'default.some.code.label', default:'Please provide your validation err msg.' )"]
}
The above throws syntax error. I am still trying to fix the syntax. Is it alrite to send the flash message in this way ?
Grails controller returns model which is in simple case just map (map with domainInstance
in your case). flash
is property which is available in controllers.
def update(){
if(certain validation fails ) {
flash.message = message(code: 'default.some.code.label', default: 'Please provide your validation err msg.')
}
[domainInstance: originalDomainInstance]
}
If you would to pass message in model map the syntax should look like below:
[domainInstance: originalDomainInstance, myMessage: message(code: 'default.some.code.label', default: 'Please provide your validation err msg.')]
Useful links: flash and models and views in Grails.