Migration from play 2.6 to 2.7 Input warnings

I’m trying to migrate and I get so many warnigs about inputs. I do not know how to solve them.

scalaVersion := "2.12.8"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.3")

And I get the following warning:

method implicitJavaMessages in object PlayMagicForJava is deprecated (since 2.7.0): See https://www.playframework.com/documentation/latest/JavaHttpContextMigration27
[warn]  @inputText(propostaForm("valor"), '_label -> "", 'id -> "idField", 'type -> "number", 'class -> "text-center", 'placeholder -> "Something*", '_showConstraints -> false)

Hi,

are you sending the Messages instance as an implicit parameter to the view, as described in the link you get in the warning? Like this:

@(propostaForm : BlablaForm)(implicit messages : play.i18n.Messages)

The migration from Play 2.6 to 2.7 requires a lot of work, so please read the migration guide carefully.

Kind regards,
Eirik

1 Like

Hello,

Yes i put @(propostaForm : BlablaForm)(implicit request: Http.Request, messages : play.i18n.Messages)
and have to change the routes path like this:
GET /path/to/example controllers.blablaController.exampleMethod(request: Request, messages: Messages)

[error] routes: not found: type Messages

Hi Elmar,

You don’t need to send the messages instance back to the controller, it’s enough to pass the request instance.

When passing the request instance to your controller you can get the message instance like this:

@Inject 
private MessagesApi messagesApi;

public Result exampleMethod(Http.Request request) {
    Messages messages = messagesApi.preferred(request);

    .....

    return ok();
}

Kind regards,
Eirik

yes it works, thanks you very much