register
other register

Friday, January 16, 2009

Clear Flash Message in Grails

According to the Grails documentation:

"Flash is a temporary storage map that stores objects within the session for the next request and the next request only, automatically clearing our the objects held there after the next request completes.

The flash object is essentially a map (a hash) which you can use to store key value pairs. These values are transparently stored inside the session and then cleared at the end of the next request.

This pattern allows you to use HTTP redirects (which is useful for redirect after post and retain values that can retrieved from the flash object."

But just in case the flash message isn't cleared for some unknow reason, there is the code to rescue in your controller:

flash.clear()

No comments: