0
votes

I'm trying to redirect to a controller method which is taking Long and String as argument by using the reverse controller. I use version 2.4 of the play framework.

I've defined this route in the routes file:

GET     /games/play/:id    controllers.Games.renderGame(id: Long, feedback: String = "")

To call this route, I'm using in a other method redirect():

return redirect(controllers.routes.Games.renderGame(gameId, "test"));

And here is my renderGame() method:

public Result renderGame(Long id, String feedback) {
   //do something
   return ok(...);
}

In my opinion this actually should work but play gives me a error:

error: method renderGame in class ReverseGames cannot be applied to given types;

IntelliJ is trying to do it better: Error picture

If I define the method just with Long as parameter it's working fine but when a add the String I get the error again.

Any idea what's wrong here?

Related to this Question, it actually should work: Play Framework: Redirect to controller method with arguments

2

2 Answers

1
votes

I fixed the problem by myself but it tooks me hours. The problem was that I used a = instead of =?. It has to look like this:

GET     /games/play/:id                 controllers.Games.renderGame(id: Long, feedback: String ?= "")
0
votes

I think the problem is with the route definition try adding feedback params at the url pattern

GET     /games/play/:id/:feedback    controllers.Games.renderGame(id: Long, feedback: String = "")

cheers.