I run Play Framework 2.2.1. I used to have only java controllers rendering templates. Now I am adding a Scala controller to render a new template indexScala.scala.html. The parameters list for indexScala.scala.html:
@()(implicit request: play.api.mvc.RequestHeader)
and it calls
@mainEmptyScala("blah", head) {}
The parameters list for mainEmptyScala.scala.html:
@(title: String, head: Html = Html(""))(body: Html)(implicit request: play.api.mvc.RequestHeader)
When I call indexScala template, I also declare request as implicit in the Scala controller. However, I got this compile error.
[error] ~/myapp/app/views/indexScala.scala.html:29: ambiguous implicit values:
[error] both method requestHeader in object PlayMagicForJava of type => play.api.mvc.RequestHeader
[error] and value request of type play.api.mvc.RequestHeader
[error] match expected type play.api.mvc.RequestHeader
[error] @mainEmptyScala("blah", head) {
[error] ^
I made sure that indexScala and mainEmptyScala templates are not called by any Java controller, so PlayMagicForJava shouldn't be used. Does anybody know how to resolve this compile error? Thanks.
After having the same problem i stumbled upon a solution. The solution that works for me that i am on Play Framework 2.3.x with Scala 2.11.1.
Just use play.api.mvc.Request everywhere in your templates:
@()(implicit request: play.api.mvc.Request[Any])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With