match case in scala template doesn’t work, in play2

I was hitting the same problem. Enclosing the right part of the case in curly braces fixed the issue for me. This works for me: @user match { case Some(user) => { Welcome, @user.username! } case None => { <a href=”https://stackoverflow.com/questions/9748258/@routes.Application.login”>Login</a> } } Without the braces, it gave an error with the space after the … Read more

Scala streaming library differences (Reactive Streams/Iteratee/RxScala/Scalaz…)

PS: I wonder why Play Iteratees library has not been choosed by Martin Odersky for his course since Play is in the Typesafe stack. Does it mean Martin prefers RxScala over Play Iteratees? I’ll answer this. The decision of which streaming API’s to push/teach is not one that has been made just by Martin, but … Read more

Route to static file in Play! 2.0

IIRC, change <link rel=”stylesheet” media=”screen” href=”https://stackoverflow.com/questions/9792875/@routes.Assets.at(“stylesheets/main.css”)”> To <link rel=”stylesheet” media=”screen” href=”https://stackoverflow.com/questions/9792875/@routes.Assets.at(“stylesheets/”, “main.css”)”> I am talking about your third attempt Also, watch out for extra / EDIT GET /assets/main.css controllers.Assets.at(path=”/public”, file=”/stylesheets/main.css”) Assuming your resource is at /public/stylesheets/main.css

How to integrate Play Framework 2.0 into Gradle build management using Maven dependencies?

This is a very tricky business. SBT in Play is used for fetching dependencies, compiling source and templates, and for the SBT incremental compilation + auto-reloading feature. I have written a build.gradle script to resolve all Play 2.0 dependencies and set-up Eclipse or IntelliJ IDEA classpaths, and made it public here. I will try to … Read more

“object index is not a member of package views.html” when opening scala play project in scala ide

Occasionally after adding a view in Play 2.4.x, IntelliJ IDEA sometimes gets confused and absolutely refuses to build. Even rebuild Project fails: This still happens from time-to-time in IDEA 15. And when it does, the command line provides the quickest, most-reliable fix: sbt clean; sbt compile That’s it! IDEA will now compile the project as … Read more

parsing a Json Array in play framework JsObject

I’d argue that it’s generally a good idea to move from JSON-land to native-Scala-representation-land as early as possible. If obj is your JsObject, for example, you can write this: val subCategories = (obj \ “sub-categories”).as[List[Map[String, String]]] val names = subCategories.map(_(“name”)) Or even: case class Category(name: String, subs: List[String]) import play.api.libs.functional.syntax._ implicit val categoryReader = ( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)