Hick
Hick

Reputation: 36374

Compilation error: not found: value nonEmptyText in Play framework while using Scala

This is my Application.Scala

package controllers

import play.api._
import play.api.data.Form
import play.api.mvc._



import _root_.scala.xml.Text


object Application extends Controller {

  def index = Action {
    Redirect(routes.Application.tasks)
  }


  def deleteTask(id: Long) = TODO

  val taskForm = Form(
  "label" -> nonEmptyText
)
def tasks = Action {
  Ok(views.html.index(Task.all(), taskForm))
}

  def newTask = Action { implicit request =>
  taskForm.bindFromRequest.fold(
    errors => BadRequest(views.html.index(Task.all(), errors)),
    label => {
      Task.create(label)
      Redirect(routes.Application.tasks)
    }
  )
}
}

I'm using play 2.0 framework. Where am I going wrong to get such an error?

Upvotes: 4

Views: 5028

Answers (2)

user3671436
user3671436

Reputation: 1

I found that restarting the server solved the issue for me.

Upvotes: 0

pedrofurla
pedrofurla

Reputation: 12783

You can browse Play 2 docs here. By looking at the index I found that nonEmptyText is contained in play.api.data.Forms object.

So, you need to either add import play.api.data.Forms._ as already suggested or replace the current not found symbol with Forms.nonEmptyText since it's already imported.

Upvotes: 5

Related Questions