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’
Strict answer : Just return your message (or render with a model map)
for your controller :
def delete() {
def instanceToDelete= Myobject.get(params.id)
try {
instanceToDelete.delete(flush: true)
redirect(action: "list", id: params.id)
}
catch (DataIntegrityViolationException e) {
render view:'delete', model:[message: "some message"]
//I want to refresh the div containing the flash.message here
}
}
for your gsp :
${message}
But Gregg is right, you should never modify client data without a redirect
.
If you do, the user might refresh (or come back to) the same url, and attempt again same action accidentally. You should really do like in hitt5's answer.