I’m trying to create a plugin for Play Framework 2.0 (latest code in Github as of today, 10th December 2011). The plugin must render some data in the view. To avoid forcing users to modify all the templates, I created a tag that will retrieve and render the relevant data.
To avoid concurrency issues that data should be stored along an identifier for the user. This identifier only needs to be valid during a request (session id, request itself, etc), after the request ends the information would be discarded.
The issue is that neither Request, RequestHeader nor Session are available as implicit values inside a Scala template. So, which are the implicit values available in a template?
If there are none I can use, do you have any suggestion on how to obtain a value that I can access from templates and controllers (without requiring a user to modify neither the controller or the template) and that can be generated in a per-request basis?
Yes it was a problem to me too…
Actually, they could have one
implicitbut still that you have to add it to the parameters list and to declare the needed object asimplicitin the Action.Here is how I did:
template
controller
More?
Since one single
implicitparameter is valid, you could wrap your needed object in a dedicated structure and declare it asimplicit.