playframework-2.0

Play Framework Form “fold” method naming rationale

半城伤御伤魂 提交于 2020-01-23 08:16:07
问题 Play Framework's (2.x) Form class has a method called fold who's usage is indicated as: anyForm.bindFromRequest().fold( f => redisplayForm(f), t => handleValidFormSubmission(t) ) Essentially, the first function parameter is what gets executed on binding failure, and the 2nd on binding success. To me it seems similar to the 'success' and 'error' callbacks of jquery's ajax function. My question is why did the Play developers call the method "fold"? As a disclaimer I am new to Scala, but I am

Scala Play upload file within a form

耗尽温柔 提交于 2020-01-22 19:45:21
问题 How would I upload a file within a form defined with Scala Play's play.api.data.Forms framework. I want the file to be stored under Treatment Image. val cForm: Form[NewComplication] = Form( mapping( "Name of Vital Sign:" -> of(Formats.longFormat), "Complication Name:" -> text, "Definition:" -> text, "Reason:" -> text, "Treatment:" -> text, "Treatment Image:" -> /*THIS IS WHERE I WANT THE FILE*/, "Notes:" -> text, "Weblinks:" -> text, "Upper or Lower Bound:" -> text) (NewComplication.apply _ )

Writing a unit test for Play websockets

怎甘沉沦 提交于 2020-01-22 18:03:07
问题 I am working on a Scala + Play application utilizing websockets. I have a simple web socket defined as such: def indexWS = WebSocket.using[String] { request => val out = Enumerator("Hello!") val in = Iteratee.foreach[String](println).map { _ => println("Disconnected") } (in,out) } I have verified this works using Chrome's console. The issue I'm having is trying to write a unit test for this. Currently I have this: "send awk for websocket connection" in { running(FakeApplication()){ val js =

Play Slick: How to inject DbConfigProvider in tests

拜拜、爱过 提交于 2020-01-20 08:10:27
问题 I am using Play 2.5.10, Play-slick 2.0.2, and my activator-generated project comes with scalatest and code like this: class TestSpec extends PlaySpec with OneAppPerSuite {...} I managed to test routes/Actions; now I would test DAO methods on a lower level. I searched the web and SO for a solution, and could not find any that is still up-to-date. A DAO signature is like this: class TestDAO @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider

Play Slick: How to inject DbConfigProvider in tests

寵の児 提交于 2020-01-20 08:09:08
问题 I am using Play 2.5.10, Play-slick 2.0.2, and my activator-generated project comes with scalatest and code like this: class TestSpec extends PlaySpec with OneAppPerSuite {...} I managed to test routes/Actions; now I would test DAO methods on a lower level. I searched the web and SO for a solution, and could not find any that is still up-to-date. A DAO signature is like this: class TestDAO @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider

How to get child record (case class) ID in Play Framework (2.4.0) using Forms

你说的曾经没有我的故事 提交于 2020-01-17 03:44:31
问题 I'm afraid I'm not seeing it yet. There must be a way, using the tools as they are intended to be used, to get the ID of a child record (many-to-one typical relational database stuff) of a series of "items" I can create a "form" (mapping) in the case class of the parent no problem. lazy val aForm = Form( mapping( "ID" -> ignored(id), "firstName" -> nonEmptyText, "lastName" -> nonEmptyText, "listOfEmails" -> seq(email), "statusID" -> ignored(0l), "roleID" -> default(longNumber, roleID),

Play! 2.1 sbt publish a dist cycle in tasks error

守給你的承諾、 提交于 2020-01-16 02:52:07
问题 Upon migrating from 2.04 to 2.1, we encountered a problem with our publish task that sends the zip file from the dist task to Artifactory. Now what we are getting is the folowing error: Internal task engine error: nothing running. This usually indicates a cycle in tasks. There is discussion about this in the play framework user groups: https://github.com/playframework/Play20/pull/535 and https://groups.google.com/forum/#!topic/play-framework/BoWw65F6vg8 We basically tried to do what they

`exception during macro expansion: [error] scala.reflect.macros.TypecheckException` when using quill

喜你入骨 提交于 2020-01-15 11:43:09
问题 I'm pretty new to Scala, Play, and Quill and I'm not sure what I'm doing wrong. I have my project split up into models, repositories, and services (and controllers, but that is not relevant for this question). Right now, I'm getting this error for the lines in my services that are making changes to the database: exception during macro expansion: scala.reflect.macros.TypecheckException: Can't find implicit `Decoder[models.AgentId]`. Please, do one of the following things: 1. ensure that

Error Deploying to Heroku Play 2.2 app

回眸只為那壹抹淺笑 提交于 2020-01-15 08:09:08
问题 I think i am having a problem in my Procfile. The deploy is compiled successfully but the app does not start with this message -- 2014-03-27T14:17:06.465302+00:00 heroku[api]: Deploy ea0e14d by xxxx@gmail.com 2014-03-27T14:17:06.465378+00:00 heroku[api]: Release v10 created by xxxx@gmail.com 2014-03-27T14:17:14.091032+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/enigmatic-dusk-7498 -Dhttp.port=32253` 2014-03-27T14:17:15.199466+00:00 app[web.1]: bash: target

Play change RUNNING_PID file path

a 夏天 提交于 2020-01-15 03:55:10
问题 I am trying to store the RUNNING_PID file at /var/run instead of root directory. Tried all the options suggested at: Another SO question about the subject and the solution play suggest in their documnetation: Play additional configuration Yet when I start my app the RUNNING_PID file is created in root directory and the /var/run/play.pid remains empty 回答1: Put play.server.pidfile.path=/var/run/RUNNING_PID in your application.conf 来源: https://stackoverflow.com/questions/35149196/play-change