In terms of a implementation of flash message in Play, I saw two ways.
Those are flash(flashKey, flashMessage)
and flash().put(flashKey, flashMessage)
where both flashKey
and flashMessage
are String
.
What exactly is the difference?
What is the difference between flash(a, b) and flash().put(a, b) in PlayFramework?
72 views Asked by Kazuya Tomita At
1
flash().put(key, message)
is the Flash class interface for adding the given value the flash scopeflash(key, message)
is the RequestBuilder interface for updating the flash session. Under the hood it does exactly the same asnew HashMap<>(flash()).put(key, message)
(source here) but it looks like it does the additional step of updating the request cookiesI believe you should use
flash(key, message)
to ensure that any updates to the flash are persisted.