Dong
Dong

Reputation: 146

Strange syntax error in play framework 2.1.1

I cloned a project from github. It is yesnault / Play20StartApp.

I downloaded the 2.1.1 version and imported it into eclipse.

I can successfully run the app but eclipse keeps telling me that there are some syntax errors in my login.scala.html and wflash.scala.html.

The login.scala.html is as below.

@(loginForm: Form[Application.Login])

@import helper._
@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapInput.render) }

<h3>@Messages("signin.signin")</h3>

@form(routes.Application.authenticate(), 'class -> "form-vertical") {

@if(loginForm.hasGlobalErrors) {
    <p class="error">
        <span class="label important">@loginForm.globalError.message</span> </p>}

//value message is not a member of Option[play.api.data.FormError]

<fieldset>
    @inputText(
        loginForm("email"),
        'placeholder -> Messages("email"),
        '_label -> null,
        '_help -> Messages("signin.your.email")
    )
    @inputPassword(
        loginForm("password"),
        '_label -> null,
        'placeholder -> Messages("password"),
        '_help -> Messages("signin.your.password")
    )
</fieldset>

<div class="form-actions">
    <input type="submit" class="btn btn-primary" value="@Messages("signin.signin")">
    <small><a href="@controllers.account.routes.Reset.ask">@Messages("forgot.password")</a></small>
</div>

}

Here is the wflash.scala.html.

@import helper._
@import helper.twitterBootstrap._

not found: value flash

@flash.map {
    case (key, value) => {
        <p class="">
            <span class="badge badge-@key">@value</span>
        </p>
    }
}

After I change @loginForm.globalError.message to @loginForm.globalError.get.message in login.scala.html, the syntax error in it will disappear.

Also, if I change wflash.scala.html to this, there will be no syntax error in it.

@(implicit flash: Flash)
@import helper._
@import helper.twitterBootstrap._

@flash.data.map {
case (key, value) => {
    <p class="">
        <span class="badge badge-@key">@value</span>
    </p>
   }
}

The problem is the app cannot run successfully after I changed them.

The web page in localhost:9000 says "not found: type Flash" and "value get is not a member of play.data.validation.ValidationError".

Who can tell me the solution? Thanks!

Upvotes: 1

Views: 322

Answers (1)

Leo
Leo

Reputation: 2189

After the checkout you shoud cd to your app folder and run play eclipse to let play create valid eclipse project for you.

Upvotes: 1

Related Questions