Play Framework 2.0 - views.render throws exception

playframework, playframework-2.0

Solution

Each view in Play 2.0 is Scala function which contains arguments, most probably you have in the index.sacala.html String declared at the beginning:

@(message: String)

and it should be your form:

in controller:

final static Form<MyModel> myForm = form(MyModel.class);

public static Result blank() {
    return ok(formNew.render(myForm));
}

and in the view:

@(myForm: Form[MyModel])  

Problem

I'm trying to get the hello world app running from the doc. I get the following error: ``` render(java.lang.String) in views.html.index cannot be applied to (play.data.Form<controllers.Application.Hello>) ``` Pointing to the following code block: ``` /** * Home page */ public static Result index() { return ok(index.render(form(Hello.class))); } ``` Also Eclipse cannot resolve the .render method on the index object. ``` the method render(String) in the type index is not applicable for the arguments (Form<Application.Hello>) ``` I defined the following imports: ``` package controllers; import play.*; import play.mvc.*; import play.data.*; import play.data.validation.Constraints.*; import java.util.*; import views.html.*; ``` Also the hello.scala.html and the index.scala.html are available in the folder app/views/ Any idea what I did wrong?

Original source