playframework-2.2

Play 2.2.3 can not see file by Play.application().resource

回眸只為那壹抹淺笑 提交于 2019-12-11 16:21:26
问题 Play 2.2.3. Windows 7. public static Result menu() throws IOException { String path = Play.application().resource("resources/menu.json").toString(); String content = Files.toString(new File(path), Charsets.UTF_8); return ok(content).as("JSON"); } Got an error: ... scala-2.10\classes\resources\menu.json The filename, directory name, or volume label syntax is incorrect Checking that path in file-system, I'm able to find my file there: ..\target\scala-2.10\classes\resources\menu.json I'm able to

Play reverse routing - getting absolute url

不羁的心 提交于 2019-12-11 13:56:23
问题 How can I get the absolute URL in play 2.2 scala when doing the following: val promoLink = routes.Promotions.promotionsCategory(DOCID, slug) //routes file GET /promotions/:DOCID:/slug controllers.Promotions.promoCat(DOCID, slug) As it stands I get a "found : play.api.mvc.Call" type mismatch on expecting a string thanks 回答1: I suppose your promoLink should be a String containing an URL? Your question sounds a bit unclear. If so then you probably need this: val promoLink = routes.Promotions

Set IGNORECASE and other options for H2 in a Play! Framework test

主宰稳场 提交于 2019-12-11 12:38:27
问题 I've setup my Play! (with Slick) application to use H2 when running tests, and it has worked great so far. I'm getting an error now, because of a plain-SQL query that uses lower-case column and table names, and H2 complains that the TABLE (all uppercase) could not be found. Now I need to set a few options, IGNORECASE for sure, and possibly the MODE . When I setup my database for tests, I use def fakeAppWithMemoryDatabase = FakeApplication(additionalConfiguration = inMemoryDatabase()) For

Can create a play 2.2.0 project — Error adding module to project: Cannot create module

孤人 提交于 2019-12-11 11:39:11
问题 I have play 2.2.0 and IntellyJ Idea 12 and Play Framework plugin for it. I can create a play project due to the error Error adding module to project: Cannot create module Why is that? 来源: https://stackoverflow.com/questions/20210729/can-create-a-play-2-2-0-project-error-adding-module-to-project-cannot-create

“value getOrElse is not a member of String” in template

我的梦境 提交于 2019-12-11 11:21:51
问题 I have the following template code: views/Login.scala.html: @(loginForm: Form[views.Data]) @import mytemplates.loginform @Main("") { email:@loginform(loginForm("email")) @*email:@loginForm("email").value.getOrElse("xyz")*@ } views/mytemplates/loginform.scala.html: @(emailField: Field) @emailField.value.getOrElse("xyz") views/Main.scala.html: @(page: String)(content: Html) <!DOCTYPE html> <html> <body> @content </html> views/Data.java: package views; import play.data.validation.ValidationError

Play Framework 2.2 (scala) play.api.cache not included as standard?

大憨熊 提交于 2019-12-11 10:47:47
问题 I am using play 2.2 (scala). I can not import play.api.cache._ as it is not found. I assume that it is not included as part of the standard download? How can I enable/get it. Do I need to included it manually in SBT build profile? Strange that an important component like caching is not included as standard. Thanks 回答1: That's correct. According to the migration guide: Play cache is now split out into its own module. If you are using the Play cache, you will need to add this as a dependency.

Advanced HTTP server configurations in Play 2.3

扶醉桌前 提交于 2019-12-11 09:09:27
问题 I am using Play 2.3 to develop an application. I need to set http.netty.log.wire to true which is by default false as specified in Play documents. In the below link (last section) it says this option is available but it also specifies "we cannot use application.conf" to specify this. https://www.playframework.com/documentation/2.3.x/ProductionConfiguration If we cannot specify this in application conf, how can we specify this? Thanks 回答1: You will need to pass those options in the command

'Cannot init the Global object' error after adding a final static constant to Global class

吃可爱长大的小学妹 提交于 2019-12-11 07:40:44
问题 I'm using Play Framework 2.2.3 with Java. I just add a constant to my Global class: public static final String VERSION = play.application().configuration().getString("application.version"); Then I get this error: play.api.PlayException: Cannot init the Global object[null] at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:55) ~[play_2.10.jar:2.2.3] at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply

Play2: play stage command fails with 'not found: type SetupContext'

让人想犯罪 __ 提交于 2019-12-11 07:14:07
问题 I'm currently trying to deploy a Play 2.2.2 application to heroku and play stage command fails for me with the following output: $ play clean compile stage [info] Loading project definition from /Users/apotapov/Dropbox/workspace/test/project [info] Set current project to test (in build file:/Users/apotapov/Dropbox/workspace/test/) [success] Total time: 0 s, completed Apr 9, 2014 4:45:28 PM [info] Updating {file:/Users/apotapov/Dropbox/workspace/test/}test... [info] Resolving org.fusesource

The role of Tuple in PlayFramework

☆樱花仙子☆ 提交于 2019-12-11 06:55:25
问题 Now I'm using play2.2.1, and I know Java, but I don't know Scala. And if you learn PlayFramework even just a little bit, you will know Scala is used in some extent in the framework. This is just a background about me. The question is why is Tuple2 used in below code although the number of passing values is one not plural. This is the controller's code: //Action for making a message public static Result add() { Form<Message> f = new Form(Message.class); List<Member> mems = Member.find.select(