Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does .flashing do in Play!2?

Can someone explain what the Flash Scope is? What does .flashing() do and how to use both of them?

like image 873
Henry Henrinson Avatar asked Feb 20 '23 20:02

Henry Henrinson


1 Answers

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 }

like image 100
Andy Petrella Avatar answered Feb 22 '23 10:02

Andy Petrella