Reputation: 9410
Under Play 1.4.x if I wanted to reverse generate a URL I might use something like:
Map<String, Object> map = new TreeMap();
map.put("myParam", myParam);
ActionDefinition ad = Router.reverse("MyAction.query", map);
String url = ad.url;
According to the unfailingly terse Play 2.x documentation, under Play 2 with Scala I'm supposed to use a Redirect:
val action = Action {Redirect(routes.MyAction.query(myParam))}
but what do I do with the action to acquire the actual URL?
Upvotes: 2
Views: 4240
Reputation: 4743
val relative = routes.MyAction.query(myParam).url
or absolute
val url = routes.MyAction.query(myParam).absoluteURL()
or absolute https
val securedUrl = routes.MyAction.query(myParam).absoluteURL(true)
Upvotes: 11