Reputation: 2534
Using Play 2.1.0, I have a Java controller with an action responsible to render arbitrary html views.
For example:
class HtmlClientViews extends Controller {
public static void getView(String viewName) {
return ok(/*How to render the view programmatically?*/)
}
}
And in my views I have a view named account.html.scala.
I have a route like:
GET /htmlclient/*viewName controllers.HtmlClientViews.getView(viewName)
If I make a request like /htmlclient/account.html I want to render the view named account.html.scala
I haven't tried yet to use Java reflection mechanisms for this, but would like to know what is the most effective way to achieve this.
Upvotes: 0
Views: 169
Reputation: 55798
You can do it with:
Play Authenticate
usage sample, there it's used for selecting different view depending on detected languagea
,b
,c
or d
.matching
statement in the view to include sub-view depending on some variable. Upvotes: 1