I'm reading the book Learn Java for Web Development and trying to execute code examples from the book.
I have a problem with Play Framework code example (chapter 8).
Exception:
"render(java.util.List,play.data.Form) in views.html.index cannot be applied to (java.lang.String)"
Controller class :
final static Form<Book> bookForm = Form.form(Book.class);
public static Result books(){
return ok(views.html.index.render(Book.all(),bookForm));
}
View - index.scala.html
@(books: List[Book], bookForm: Form[Book])
@import helper._
@main("books") {
<h1>@books.size() book(s)</h1>
<ul>
@for(book <- books) {
<li>
@book.label
@form(routes.Application.deleteBook(book.id)) {
<input type="submit" value="Delete">
}
</li>
}
</ul>
<h2>Add a new book</h2>
@form(routes.Application.newBook()) {
@inputText(bookForm("label"))
<input type="submit" value="Create">
}
}
Edit:
1) I just installed latest play version from scratch on Windows 8 machine, for the moment it's Play 2.3.1 . I didn't any modifications for Play framework . It's my first play project
2) Full error (in Eclipse): The method render(String) in the type index is not applicable for the arguments (List<Book>, Form<Book>)
3) When I try to refresh my browser , code compiled and I can see Book form on a screen
ApplicationTestfile, just delete that file; it seems to be a leftover from the default application template that is not correct in this project. - Fernando Correia