Image with error <--- when I use function update, I want to redirect to BooksController.index() but when i try it I have an error: object java.lang.ProcessBuilder.Redirect is not a value. Can somebody help?
BooksController:
val bookForm = Form(
tuple(
"id" -> number,
"title" -> text,
"price" -> number,
"author" -> text
)
)
def edit(Id: Int) = Action {
val book: Book = Book.findById(Id)
Ok(views.html.edit())
}
def update(Id: Int) = Action {
implicit request =>
val (id, title, price, author) = bookForm.bindFromRequest.get
val book: Book = Book.findById(id)
book.id = id
book.title = title
book.price = price
book.author = author
Redirect(routes.BooksController.index())
}
My edit view:
<html>
<head>
<title>Form example</title>
</head>
<body>
<form method="post" autocomplete="on">
Id: <input type="text" name="id"><br><br>
Title: <input type="text" name="title"><br><br>
Price:<input type="text" name="price"><br><br>
Author: <input type="text" name="author"><br><br>
<input type="submit">
</form>
</body>
</html>
Routes:
GET /books controllers.BooksController.index
GET /books/create controllers.BooksController.create
GET /books/:id controllers.BooksController.show(id: Int)
POST /books/create controllers.BooksController.save
GET /books/edit/:id controllers.BooksController.edit(id: Int)
POST /books/edit controllers.BooksController.update
Error: play.sbt.PlayExceptions$CompilationException: Compilation error[object java.lang.ProcessBuilder.Redirect is not a value] at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:34) at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:34) at scala.Option.map(Option.scala:146) at play.sbt.run.PlayReload$.$anonfun$taskFailureHandler$1(PlayReload.scala:33) at scala.Option.map(Option.scala:146) at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:28) at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:24) at play.sbt.run.PlayReload$.$anonfun$compile$3(PlayReload.scala:51) at scala.util.Either$LeftProjection.map(Either.scala:573) at play.sbt.run.PlayReload$.compile(PlayReload.scala:51)