Reputation: 4435
play doesn't convert my java form object to the scala world.
[error] /home/myproject/split/frontend/app/controllers/frontend/Configuration.java:46: error: method render in class settings cannot be applied to given types;
[error] return ok(settings.render(settingsForm.fill(userSettings)));
[error] ^
[error] required: play.api.data.Form<Settings>
[error] found: play.data.Form<Settings>
[error] reason: actual argument play.data.Form<Settings> cannot be converted to play.api.data.Form<Settings> by method invocation conversion
the view-template looks like this:
@(settingsForm: Form[Settings])
@import play.i18n._
@import helper._
@import helper.twitterBootstrap._
@main {
@helper.form(action = controllers.frontend.routes.Configuration.setSettings) {
Any idea?
I should also mention that we use project split main->frontend->common
and main->backend->common
. We moved this page (view and controller) from common
to frontend
. It worked in common
fine. Now in frontend
I get this error.
I actually had a similar problem with a java.util.List
and I had to add templatesImport ++= Seq("java.util._", ...
to the settings:
val frontend = play.Project(
appName + "-frontend", appVersion, path = file("main/frontend")
).settings(
templatesImport ++= Seq("java.util._", "models.frontend._")
).dependsOn(common).aggregate(common)
I tried with play.data._
already, didn't help.
Upvotes: 1
Views: 1891
Reputation: 12850
Your frontend project is a Scala project, not a Java project. Add a dependency on javaCore to it, and it will be a Java project. Then do a play clean compile, and everything should work. Eg:
val frontend = play.Project(
appName + "-frontend", appVersion, Seq(javaCore), path = file("main/frontend")
).settings(
templatesImport ++= Seq("java.util._", "models.frontend._")
).dependsOn(common).aggregate(common)
Upvotes: 1