1
votes

I am a beginner to Play framework and Scala, I'm trying to develop a simple web project with Play on Scala, I'm using the eclipse IDE!

My problem is when I change the parameter of a view template, despite the fact that I pass the "same new" parameter in the Action calling this view, I have an error like this:

type mismatch; found : Int required: String

To simplify, assuming we have a view that takes as parameter @(value:String) so I can call this view from an Action Ok(html.say(value)) such as value is declared as String.

In this case, all is well!

But when I change the parameter of the view to take an Int @(value:Int) and I call this view from the Action with Ok(html.say(value)) despite I changed the type of value from String to Int, I get:

Compilation error: type mismatch; found : Int required: String

I did a clean on the project but it didn't help. What is the problem?

2
This could either be a problem with Play or Scala IDE. Where do you see the error? In the browser when you refresh the page, or in Eclipse? Templates are compiled in a different manner to other standard code, so if it's the latter your IDE may just not be seeing the recompiled template. - Mikesname
Thanks for your reply, the error appears in Eclipse! - Momog
Eclipse won't compile templates. Ignore its errors, specially when related to templates. - pedrofurla

2 Answers

2
votes

Make sure you compile from the Play console, either by typing compile or by reloading your page (when you are running the application). That will recompile the template. Then you can refresh Eclipse to make it pick up the changes.

2
votes

Before posting any questions on Play Framework "play clean compile" command should be run. It resolves 95% of such issues.