Scala – Play Scala Application “not found: value action”

playframeworkplayframework-2.0scala

I'm following the instructions in the article http://scala.playframework.org/documentation/scala-0.9.1/hello-world

I have installed Typesafe Stack 1.1 and Play! Framework 2.0 beta.

When I modify the file index.scala.html to

@(message: String)

@main("Welcome to Play 2.0 beta") {
    <form action="@action(controllers.Application.index)" method="GET">
        <input type="text" name="myName" /> 
        <input type="submit" value="Say hello!" />
    </form>
}

the page fails to compile with the error message not found: value action.
I have determined that it also fails to compile with other helpers. I've Googled for a solution and not come up with anything. I'm completely new to Scala and would appreciate any help.

Best Answer

I have just started myself with play and scala I found that play 2.0 isn't something one should start with.

There seems to be much lacking in play 2.0 and much of the tutorials is for play 1.x. For example I lost some time with play eclipify just to find in a bug archive that such "comfort" isn't implemented in play 2.0. So I would recommend to learn scala with play 1.

And in your step in the tutorial (tutorial for play 1 I dont know for play 2) you should change:

controllers.Application.index  to  controllers.Application.sayHello

add to contollers.scala

def sayHello = html.sayHello(params.get("myName"))

Add this file helloworld/app/views/Application/sayHello.scala.html:

@(name:String)

  @main(title = "Hello") {

  <h1>Hello @(name ?: "Guest")!</h1>

  <a href="@action(controllers.Application.index)">Back to form</a>

}
Related Topic