Reputation: 92407
How can I add an URL fragment (#xyz
) to a link created by the Redirect
method?
I want something like this:
Redirect(routes.Comment.get(itemId) + "#xyz")
Upvotes: 3
Views: 775
Reputation: 672
With Play Framework 2.4 is possible do this:
Redirect(routes.Comment.get(itemId).withFragment("#xyz").toString)
Upvotes: 2
Reputation: 11479
You can get the url form the route using .url (which contains a relative url). Redirect needs two parameters to accept a string to redirect to
so, Redirect(routes.Comment.get(itemId).url + "#xyz", SEE_OTHER)
should work
Edited when I realized Redirect() takes a Call and not a string
Upvotes: 2