I’m new to Grails, and I have a question that should be easy for most of you.
I have a page displaying an object
list. I want to display a message if there’
This can help you:
def delete() {
def instanceToDelete= Myobject.get(params.id)
try {
instanceToDelete.delete(flush: true)
flash.success = "Object deleted correctly"
} catch (DataIntegrityViolationException e) {
flash.error = "Something goes wrong"
}
redirect(action: "list", id: params.id)
}
redirect to the gsp after all the code, to can store if there is an error or everything goes well.
you can put the messages in different variable to discriminate between error and success.
${flash.success}
${flash.error}