4
votes

I'm trying to set up a route in the Playframework 2.0 (Scala) that includes optional parameters in the query string, following the examples in the documentation:

GET   /my/path   controllers.foo.Bar.list(offset: Int ?= 0, limit: Int ?= 20)

However when compiling, I get the following error message:

object controllers.foo.Bar does not take parameters

I made sure that the controllers.foo.Bar.list method does in fact take two Ints as parameters. One key observation (I hope) may be that this used to work previously, when I had the Controller class directly in the controllers package, i.e.

controllers.Bar.list

But it ceased working as soon as I introduced a "foo" subpackage in Controllers.

Any input on what I'm doing wrong highly appreciated!

UPDATE: Sorry - I did some more experimenting and it seems the reason is something entirely different (d'oh). In my concrete case, my controller class was

controllers.foo.List.list

and that seemed to cause a name clash. Renaming to something else ("FooList") solved the issue.

1
Small additional note: as soon as I turn the optional parameters to fixed parameters (offset: Int = 0, limit: Int = 20) compilation is successful. I.e. I'm beginning to suspect this might actually be a bug in play? - aboutgeo
Yes, probably. Please file a ticket in the play tracker - Julien Richard-Foy
Ok - reposted this on the play tracker as suggested - Thx! - aboutgeo

1 Answers

3
votes

For anyone discovering this question, it seems very likely that this was due to a bug in the Play Framework.

You can follow its progress on the issue tracker ticket.