playframework-2.4

Play Framework 2.4 use injected variable in Scala template

霸气de小男生 提交于 2019-11-30 09:51:46
问题 I would like to show some data from the database in the menubar of my web page. To get the data, I have a data-access-object (DAO) which is usually created with Guice injection. How can I use such an (injected) object in my Scala templates? I could pass it as a parameter to the template, but I had to do this on every single page (because it should be displayed in the menubar). I'm looking for another solution where I don't have to pass it everywhere. Currently I'm creating a new object inside

Specs2: how to test a class with more than one injected dependency?

时光怂恿深爱的人放手 提交于 2019-11-28 12:18:09
Play 2.4 app, using dependency injection for service classes. I found that Specs2 chokes when a service class being tested has more than one injected dependency. It fails with " Can't find a constructor for class ... " $ test-only services.ReportServiceSpec [error] Can't find a constructor for class services.ReportService [error] Error: Total 1, Failed 0, Errors 1, Passed 0 [error] Error during tests: [error] services.ReportServiceSpec [error] (test:testOnly) sbt.TestsFailedException: Tests unsuccessful [error] Total time: 2 s, completed Dec 8, 2015 5:24:34 PM Production code , stripped to

Trouble-shooting CORS in Play Framework 2.4.x

北战南征 提交于 2019-11-28 12:12:18
I have a java play framework 2.4.x web app providing a JSON/HTTP API. When I run my front-end HTML/JS file:///Users/nize/tmp/index.html calling the API on http://localhost:9000 chrome shows XMLHttpRequest cannot load http://localhost:9000. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403. I have configured the web app as per the instructions given in Play Framework 2.4.x CORS Documentation : Update to build.sbt Added the class Filters.java to the root of the project (also tried

How to correctly schedule task in Play Framework 2.4.2 scala?

隐身守侯 提交于 2019-11-27 21:50:10
问题 Trying to schedule tasks like this in Play Framework 2.4.2 Scala without luck: import akka.actor.Actor import play.api.libs.concurrent.Akka import scala.concurrent.duration._ import play.api.Play.current import scala.concurrent.ExecutionContext.Implicits.global class Scheduler extends Actor { override def preStart() { val dbupdate = Akka.system.scheduler.schedule( 0.microseconds, 5.minutes, self, "update") val pictureClean = Akka.system.scheduler.schedule( 0.microseconds, 30.minutes, self,

Trouble-shooting CORS in Play Framework 2.4.x

独自空忆成欢 提交于 2019-11-27 06:57:36
问题 I have a java play framework 2.4.x web app providing a JSON/HTTP API. When I run my front-end HTML/JS file:///Users/nize/tmp/index.html calling the API on http://localhost:9000 chrome shows XMLHttpRequest cannot load http://localhost:9000. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403. I have configured the web app as per the instructions given in Play Framework 2.4.x CORS

Specs2: how to test a class with more than one injected dependency?

て烟熏妆下的殇ゞ 提交于 2019-11-27 06:09:22
问题 Play 2.4 app, using dependency injection for service classes. I found that Specs2 chokes when a service class being tested has more than one injected dependency. It fails with " Can't find a constructor for class ... " $ test-only services.ReportServiceSpec [error] Can't find a constructor for class services.ReportService [error] Error: Total 1, Failed 0, Errors 1, Passed 0 [error] Error during tests: [error] services.ReportServiceSpec [error] (test:testOnly) sbt.TestsFailedException: Tests

Play 2.4: Form: could not find implicit value for parameter messages: play.api.i18n.Messages

不羁岁月 提交于 2019-11-27 00:37:06
I am new to Play framework and tried to mimic the helloworld sample in my local machine but I encountered an error: routes: # Home page GET / controllers.Application.index # Hello action GET /hello controllers.Application.sayHello # Map static resources from the /public folder to the /assets URL path GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) controller: package controllers import play.api.mvc._ import play.api.data._ import play.api.data.Forms._ import views._ class Application extends Controller { val helloForm = Form( tuple( "name" -> nonEmptyText, "repeat"

Play 2.4: Form: could not find implicit value for parameter messages: play.api.i18n.Messages

六月ゝ 毕业季﹏ 提交于 2019-11-26 09:27:52
问题 I am new to Play framework and tried to mimic the helloworld sample in my local machine but I encountered an error: routes: # Home page GET / controllers.Application.index # Hello action GET /hello controllers.Application.sayHello # Map static resources from the /public folder to the /assets URL path GET /assets/*file controllers.Assets.versioned(path=\"/public\", file: Asset) controller: package controllers import play.api.mvc._ import play.api.data._ import play.api.data.Forms._ import