In a grails3 create view, I'd like to have the Cancel button which just points back to the index page. On the index page, I'd like to display a message informing about the cancellation.
<g:link controller="${controllerName}" action="index" class="btn btn-default" params="[flash.message: 'Create cancelled']">
Cancel
</g:link>
The above button is just a non-working mockup, no message is popping up. What would be the best way to achieve a flash.message
popping up on the next page?
You could just redirect from a cancel action say:
gsp
<g:link controller="${controllerName}" action="cancel" class="btn btn-default">
Cancel
</g:link>
Controller
def cancel(){
flash.message = message( code: 'cancel.message.in.messages.properties' )
redirect(action: 'index')
}