playframework-2.0

Play framework template automatically imports models._ among other things

北战南征 提交于 2019-12-21 02:51:32
问题 It seems like in Play framework templates, there is an implicit "@import models._" and "@import play.api.data.Form" because my code: @(title: String)(myForm: Form[User]) <!DOCTYPE html> <html> .... </html> works without having to put explicit import statements after the first line. This issue has been raised in the past: https://groups.google.com/d/msg/play-framework/7FT68jd5asU/xYF0VNySJYcJ What other classes/objects are implicitly imported? 回答1: You're right, Play Framework automatically

Play 2.0 with Eclipse 3.6, Scala template editing

Deadly 提交于 2019-12-21 01:22:30
问题 I´m new to Play and Scala world, so I´m needing some help to figure out how can I edit the scala template files using Eclipse. I already installed scala ide 2.9 but when I try to edit the index.scala.html, the contents of the file aren´t editable... Please can anyone help me? 回答1: I experienced this just recently, too, but lucky for you I made the full migration from IntelliJ to Eclipse. There is some setting up you need to do with the Scala templates, but one of the easiest ways to get it

Play 2.0 FakeApplication setup with test configuration

空扰寡人 提交于 2019-12-20 12:37:00
问题 I have a specs2 test which uses a FakeApplication and an embedded mongodb database. def inMemoryMongoDatabase(name: String = "default"): Map[String, String] = { val dbname: String = "play-test-" + scala.util.Random.nextInt Map( ("mongodb." + name + ".db" -> dbname), ("mongodb." + name + ".port" -> EmbeddedMongoTestPort.toString)) } override def around[T <% Result](t: => T) = { running(FakeApplication(additionalConfiguration = inMemoryMongoDatabase(), additionalPlugins = Seq("se.radley.plugin

Less Verbose way of generating Play 2's javascript router

妖精的绣舞 提交于 2019-12-20 12:32:35
问题 Currently I define my app's javascript router in a fairly verbose way def javascriptRoutes = Action { implicit request => import routes.javascript._ Ok(Routes.javascriptRouter("jsRoutes")( Login.method1,Login.Method2, OtherController.method1,OtherController.method2, //[...] )).as("text/javascript") } What I really would like to do is to create a javascriptRouter with all of the routes in the routes file, so I don't have to manually update the javascriptRoutes definition each time I add a new

Google Chrome gives warning Resource interpreted as Font but transferred with MIME type application/octet-stream:

微笑、不失礼 提交于 2019-12-20 10:28:10
问题 I keep getting this warning Resource interpreted as Font but transferred with MIME type application/octet-stream: "http://127.0.0.1:8080/assets/font/fontawesome-webfont.woff". I am using Play 2.0.4 webserver. I added the mime-types to my application.conf file as follows mimetype.eot = application/vnd.ms-fontobject mimetype.otf = application/octet-stream mimetype.ttf=application/x-font-ttf mimetype.woff = application/x-font-woff Any idea what I may be doing wrong. 回答1: Actually, I found the

How to pass raw html to Play framework view?

痴心易碎 提交于 2019-12-20 10:25:33
问题 I'm trying to pass a simple URL to a view within a play framework app, however when passed as a string, the & in the url is changed to & which causes the URL to not work. If I change the argument to Html, i.e @(url: Srting) to @(url: Html) , then I get an error when I try to pass the url as string to view.render() method. How can I convert the url into Html and pass it as that? 回答1: To prevent the default escaping that happens for dynamic content on views you need to wrap the String with

Sending the email to the following server failed : smtp.gmail.com:25

自作多情 提交于 2019-12-20 10:19:20
问题 When I try to send a mail from scala Playmework, I got following error, [ERROR] [10/10/2013 13:31:16.263] [play-akka.actor.default-dispatcher-75] [TaskInvocation] Sending the email to the following server failed : smtp.gmail.com:25 org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:25 at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242) at org.apache.commons.mail.Email.send(Email.java:1267) at com.typesafe.plugin

Using Eclipse with Play Framework 2.0

扶醉桌前 提交于 2019-12-20 09:23:52
问题 I am new to Framework 2.0. In Play 1.0, after you Eclipsify your project, you have have a *.launch file that you can use to launch your project. After you eclipsify in Play 2.0, you don't seem to have anything similar. Is there a way to control your launching and to debug Play 2.0, using Eclipse? A similar question: Debug Playframework 2.0 in Eclipse The answer to that question did not have specific enough instructions for me to know how to follow. 回答1: Question 1: After you have eclipsified,

Play! framework - database issue with Evolutions

烂漫一生 提交于 2019-12-20 09:20:00
问题 I'm using Play! framework 2.0 and I'm stuck on an annoying issue involving the database. Suppose I have a User (extends Model ) class which has few attributes ( first_name , last_name , email , password etc). At some point I want to add a new attribute, lets say last_ip (it doesn't really matter what it is). So, I add the attribute to the User class, compile and run. The thing is: I get this red alert about database changes (obviously) which asks me to press "APPLY CHANGES" (if I remember

Get rid of Scala Future nesting

天涯浪子 提交于 2019-12-20 08:30:00
问题 Again and again I am struggling when a function relies on some future results. This usually boils down to a result like Future[Seq[Future[MyObject]]] To get rid of that I now use Await inside a helper function to get a non-future object out and reduce the nesting. It looks like this def findAll(page: Int, perPage: Int): Future[Seq[Idea]] = { val ideas: Future[Seq[Idea]] = collection.find(Json.obj()) // [...] ideas.map(_.map { // UGLY? idea => { // THIS RETURNED A Future[JsObject] before val