Can someone explain what the Flash Scope is? What does .flashing() do and how to use both of them?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Roughly flashing is useful in the cases you need a temporary parameter. Common case is a message to be displayed to the next page accessed using a redirect
This is very useful when you need information part of a workflow but which you don’t want them to be part of the contract declared by a template (parameters).
A flashed information is stored in the cookie not hashed (in clear thus) and its lifetime is scoped to the very next request — discarded after.
The way to use flashing is simply use flashing which a sequence of strings kvp, like so
Redirect(routes.Application.login()).flashing(“error”, “You must be logged in”)
Where login is using a template to be rendered which contains
@flash.get(“error”) map { x =>
@x
}