Play Framework - Redirect with params

playframework, playframework-2.0, scala

Solution

Ellou'

A route is just a function, so you can pass arguments as usual:

// Redirect to /hello/Bob
def helloBob = Action {
    Redirect(routes.Application.hello("Bob"))    
}

This snippet comes from http://www.playframework.org/documentation/2.0/ScalaRouting (at the bottom)

Problem

I am trying to figure out how to do a redirect within a controller action in Play (2.0) using Scala. The redirect using ``` Redirect(routes.Application.index) ``` works just fine. What I cannot figure out from the docs, API, or Google is how to add parameters to the call. I am coming from Grails where this could be done easily as follows: redirect action: "index", params: ["key": "value"] . The only way I have found is to call Redirect using a string url and a query string, which seems awkward. Basically I would like to make use of Redirect(Call) somehow, but I do not how to create the Call object using reverse routing. Am I missing something/not getting the concept in Play/Scala? Thanks in Advance!

Original source