playframework-2.1

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

Playframework settings depending on environment

泪湿孤枕 提交于 2019-12-20 10:42:36
问题 I'm using playframework 2.1-RC2. First of all I've seen all the similar questions, so I followed the common instruction of separating application.conf file per environment. So I have application.test.conf and I run tests this way: play -Dconfig.file=./conf/application.test.conf "test" I tried different combinations, like play -Dconfig.file=./conf/application.test.conf ~test or play -Dconfig.file=conf/application.test.conf ~test Still no luck, it just does not get picked, default one

Play 2.1 SSL Configuration

a 夏天 提交于 2019-12-18 13:23:03
问题 I'm new to Play and in the process of configuring SSL for production. I can successfully run in dev mode with a self signed certificate, but when I try to use a signed certificate the initial client handshake fails and Play generates the following stack trace: play - Error loading HTTPS keystore from conf/keystore.jks java.security.NoSuchAlgorithmException: RSA KeyManagerFactory not available at sun.security.jca.GetInstance.getInstance(GetInstance.java:159) ~[na:1.7.0_11] at javax.net.ssl

How to replace a JSON value in Play

最后都变了- 提交于 2019-12-18 12:53:16
问题 How do I replace a value in a JSON value in Play? Code to illustrate: def newReport() = Action(parse.json) { request => var json = request.body if((json \ "customerId").as[Int] == -1){ // replace customerId after some logic to find the new value } json.validate[Report](Reports.readsWithoutUser).map { case _: Report => 回答1: According to the Play Documentation, JsObjects have a method ++ that will merge two JsObjects. So, when you have your new integer value, you simply need: val updatedJson =

Assets is already defined as object Assets

孤者浪人 提交于 2019-12-18 04:59:29
问题 I am doing more extended tests for Play Subproject feature as described here: http://www.playframework.com/documentation/2.0/SBTSubProjects. But I am getting the error: Assets is already defined as object Assets Sample application hosted on github: https://github.com/adis-me/PlayStrap I have defined an Asset controller for my subprojects as described here: Asset Controller description, even for the main project, but the error keeps popping up. What is wrong with my project? Controller package

Play framework handling session state

北战南征 提交于 2019-12-18 04:42:11
问题 I have a Webapp that is built on top of the Play framework and Scala. It is about presenting the user with a set of questions with each question having a set of answers. Some of the questions have radio button types an answers and some have check boxes as answers. When the user clicks start test, I call the controller, fetch the list of questions with its answers and return the result as a case class to the view template. I now need to maintain the state of the test as the user answers each

Play framework handling session state

浪尽此生 提交于 2019-12-18 04:42:09
问题 I have a Webapp that is built on top of the Play framework and Scala. It is about presenting the user with a set of questions with each question having a set of answers. Some of the questions have radio button types an answers and some have check boxes as answers. When the user clicks start test, I call the controller, fetch the list of questions with its answers and return the result as a case class to the view template. I now need to maintain the state of the test as the user answers each

Testing a Play2 application with SecureSocial using dependency injection

廉价感情. 提交于 2019-12-18 04:24:08
问题 Thanks a lot for any guidance! The SecureSocial plugin works fine when I run it from the browser, but I would like to be able to test the rest of my Play app now. Quick Intro SecureSocial's syntax looks like this: def page = SecuredAction(WithProvider("google")) { ... } or this: def page = UserAwareAction { ... } I've been looking here, which seems to be the only question on Stack Overflow even remotely related to my problem with SecureSocial, but I don't quite fancy rewiring bytecode. There

Scala to JSON in Play Framework 2.1

冷暖自知 提交于 2019-12-17 22:08:42
问题 I'm trying to convert Scala to JSON in the 2.1RC Play Framework. I can do the following and get JSON: import play.api.libs.json._ val a1=Map("val1"->"a", "val2"->"b") Json.toJSon(a1) Because a1 is just Map[String,String] that works OK. But if I have something more complex like where I have Map[String,Object], that doesn't work: val a = Map("val1" -> "xxx", "val2"-> List("a", "b", "c")) Json.toJSon(a1) >>> error: No Json deserializer found for type scala.collection.immutable.Map[String,Object]

Play Framework - Using Javascript Variable in Scala Template

拜拜、爱过 提交于 2019-12-17 19:22:10
问题 So I have something that looks like this: <script> $(document).ready(function(){ $("button.fadeMeOut").click(function(){ var fadeID = $(this).attr('id'); window.location.href = '@routes.Application.function(fadeID)'; }); }); </script> Of course this code will give a not found: value fadeID error. Is there a way for me to do something like this in Play Scala template? 回答1: You can insert the relative URL in place of '@routes.Application....etc' So for example "/function/" + fadeID If the route