Answer the question
In order to leave comments, you need to log in
Play Framework global storage in request?
Does PlayFramework have a global store where you can store the states of sidebars, bread crumbs, etc? Something unique per request, but something that can be accessed from both the controller and the model and the view?
Answer the question
In order to leave comments, you need to log in
Right. By and large, scala templates are ordinary classes (in the end), and accordingly, you can do almost everything in them that is available in the language, given only syntax restrictions.
Session Scope is not designed to store large objects. In addition, this very session does not affect the time of the request, but the time the client is working with the application. Flash is used to store data between requests. Such a temporary storage in case you need to transfer data from one request to another. For example, during a redirect.
I would use something like play.mvc.Http.Context and it has an args field. It is just designed to store the data that is needed specifically for the current request. In a controller, you can use it like this:
ctx().args.put("key", 1);
ctx().args.get("key");
And in the model like this:
Context.current().args.get("key");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question