Reputation: 20204
We have a version on our website that is published.
Is there a way to
either call a static method to get that from the html pages OR can we
put it in some kind of application context to be retrieved as I saw a
template has access to the session (which hopefully has a link to the
application context or is it still called the servlet context) and if
so, is there an initialization block for the application that I can
stuff the version in at that point?
Upvotes: 0
Views: 992
Reputation: 54914
Play does not conform to the Java EE spec, so servlet context does not exist.
If in your template you want access to static data, then it is fairly trivial. You can access it using fully qualified names in the template engine, but this couples your Java to your template engine, which is not a great idea. A better approach would be pass an object to the template (using renderArgs and the @Before annotation). I have described this approach in another post here - Play Framework Template Engine, static member passed to render cause NullPointerException
Upvotes: 3