Play Framework global repository in the query?

Does PlayFramework global storage where you can store the state of the sidebars, bread crumbs, etc? Something unique for each request, but something that can be accessed from the controller and from the model, and from a view function?
October 3rd 19 at 04:03
3 answers
October 3rd 19 at 04:05
True. By and large, scala templates are normal classes (eventually), and accordingly, you can do almost everything that is available in the language given only the restrictions of the syntax.
October 3rd 19 at 04:07
Perhaps you mean Session Scope and Flash Scope. Read more
No, I mean the global object, which you can access from anywhere: template controller.

For example Breadcrumbs (bread crumbs)

In the controller I do something like that
Breadcrumbs.add("/", "Home")
Breadcrumbs.add("/projects", "Projects")
Breadcrumbs.add("/projects/breadcrumbs-module", "Breadcrumbs Module PlayFramework")

In the template something like this
@for(node <- {
 <a href="@node.href">@node.title</a>
- Eldred.Reynolds commented on October 3rd 19 at 04:10
And all I answered your question. I can of templates Dostum to models to.

How it is sometimes useful to simply think. - Eldred.Reynolds commented on October 3rd 19 at 04:13
October 3rd 19 at 04:09

Session Scope is not designed to store large objects. In addition, this is the session does not act on the request time and the time of the client application. Flash is used to store data between requests. This temporary storage in case of a single query need to pass the data to another. For example during a redirect.

I would use such a thing as play.mvc.Http.Context and in it there is a field args. It just intended for storage of data that is needed for the current request. In the controller you can use this:

ctx().args.put("key", 1);

But in a model like this:


Find more questions by tags Play FrameworkScala