playframework-2.2

How to run Play 2.2.x with Akka 2.3.x?

痴心易碎 提交于 2019-11-28 03:09:56
问题 Is there any way to combine akka 2.3 and play 2.2? For now I'm getting AbstractMethodError while running such application. I need to have them both in one app because Akka 2.3 comes with very useful akka persistence module which is very reliable(in opposition to it's predecessor) and such reliability is really important in my case. I've tried compiling play 2.2.2 from sources and changing akka dependency there to 2.3 but i still get the same error: [ERROR] [04/01/2014 09:42:26.105] [play-akka

How to use TLS in Play!Framework WebSockets (“wss://”)

北战南征 提交于 2019-11-27 19:53:11
I cannot use wss:// in my simple WebSocket app created with Play!Framework 2.2. It echoes the message back. The endpoint is like this def indexWS2 = WebSocket.using[String] { request => { println("got connection to indexWS2") var channel: Option[Concurrent.Channel[String]] = None val outEnumerator: Enumerator[String] = Concurrent.unicast(c => channel = Some(c)) // Log events to the console val myIteratee: Iteratee[String, Unit] = Iteratee.foreach[String] {gotString => { println("received: " + gotString) // send string back channel.foreach(_.push("echoing back \"" + gotString + "\"")) }}

Expose Play Framework rest calls secured via securesocial to mobile app

我与影子孤独终老i 提交于 2019-11-27 10:11:48
问题 I would like to expose my Play Framework REST calls to clients other than my play app. I would like a mobile app to call those secured rest calls. I asked a question on SO earlier in the year and got an answer but this only works for OAuth2 and I am only using OAuth1 My questions are: Is exposing my REST calls secured by Securesocial on my PlayFramework app to non web clients like Mobile apps a good idea? Is there a way to do this using Securesocial for OAuth1? Are there any examples apart

Displaying image object from controller in the browser

烂漫一生 提交于 2019-11-27 03:38:03
问题 I use playframework 2.2.1 with Java, I am trying to pass BufferedImage or ByteArray or ByteArrayInputStream to view template in order to display it in browser directly from memory, without saving to server storage. in my view template I request an image: <img src="@{Application.getImage()}"/> my Application controller: public static Result getImage() throws IOException{ BufferedImage image = ImageIO.read(new File("public/img/1.jpg")); //some image manipulations ByteArrayOutputStream baos =

How get application version in play framework and build.sbt

[亡魂溺海] 提交于 2019-11-27 03:31:17
问题 I'm using play 2.2 with Scala, how can I get version from build.sbt? name := "project_name" version := "0.2-SNAPSHOT" play.Project.playScalaSettings or how can I pass there value from another object? 回答1: I've added this to my build.sbt: import com.typesafe.config._ val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve() version := conf.getString("app.version") and in my application.conf: app.version="0.2-SNAPSHOT" 回答2: Take a look at the solution using the application

Defaults for missing properties in play 2 JSON formats

一笑奈何 提交于 2019-11-27 00:32:38
I have an equivalent of the following model in play scala : case class Foo(id:Int,value:String) object Foo{ import play.api.libs.json.Json implicit val fooFormats = Json.format[Foo] } For the following Foo instance Foo(1, "foo") I would get the following JSON document: {"id":1, "value": "foo"} This JSON is persisted and read from a datastore. Now my requirements have changed and I need to add a property to Foo. The property has a default value : case class Foo(id:String,value:String, status:String="pending") Writing to JSON is not a problem : {"id":1, "value": "foo", "status":"pending"}

IntelliJ IDEA Report Highlighting error when using routes in Controller

情到浓时终转凉″ 提交于 2019-11-26 23:58:16
问题 I have a Scala Play project. I'm using Play 2.2.1. I downloaded Scala, Play 2 supported and SBT plugins. Everything is OK, but When I call route on Action in the Controller appear following error(Look screenshots): I'm using IntelliJ IDEA 12.1.6 Ultimate version. Scala version 2.10.2 Anybody know how to fix this problem? Thanks in advance! Edit When I generate my project to Intellij IDEA via "play idea" command in play console, and I opened project in IDEA project structure was such: Then I

How to use TLS in Play!Framework WebSockets (“wss://”)

对着背影说爱祢 提交于 2019-11-26 22:52:20
问题 I cannot use wss:// in my simple WebSocket app created with Play!Framework 2.2. It echoes the message back. The endpoint is like this def indexWS2 = WebSocket.using[String] { request => { println("got connection to indexWS2") var channel: Option[Concurrent.Channel[String]] = None val outEnumerator: Enumerator[String] = Concurrent.unicast(c => channel = Some(c)) // Log events to the console val myIteratee: Iteratee[String, Unit] = Iteratee.foreach[String] {gotString => { println("received: " +

Are there any benefits in using non-async actions in Play Framework 2.2?

拥有回忆 提交于 2019-11-26 16:56:21
问题 The Play 2.2 documentation states that: Because of the way Play works, the action code must be as fast as possible (ie. non blocking). So what should we return as result if we are not yet able to generate it? The response is a future result! A Future[Result] will eventually be redeemed with a value of type Result. By giving a Future[Result] instead of a normal Result, we are able to quickly generate the result without blocking. Then, Play will serve this result as soon as the promise is