playframework-2.5

Play 2.5: get response body in custom http action

六月ゝ 毕业季﹏ 提交于 2019-12-12 09:11:43
问题 I'm trying to create a custom http action (https://playframework.com/documentation/2.5.x/JavaActionsComposition) to log request and response bodies with Play 2.5.0 Java. This is what I've got so far: public class Log extends play.mvc.Action.Simple { public CompletionStage<Result> call(Http.Context ctx) { CompletionStage<Result> response = delegate.call(ctx); //request body is fine System.out.println(ctx.request().body().asText()) //how to get response body string here while also not

How to perform leftJoin on tables from different databases(data sources) using Scala Slick?

吃可爱长大的小学妹 提交于 2019-12-12 04:29:11
问题 I have 2 databases (database1 and database2). database1 has table1 with field id database2 has table2 with field id Now how do i perform leftJoin(as shown below) using Slick? SELECT tb1.`id` FROM `database1`.`table1` t1 LEFT JOIN `database1`.`table2` t2 ON t1.`id`=t2.`id` 回答1: I may be wrong here but most existing relational databases don't allow you to span multiple databases within single operation. However, what you showed above is easily achievable by using schema (and I strongly believe

Named event stream with Play 2.5 and server sent events

二次信任 提交于 2019-12-12 04:02:54
问题 Default event name/type in server sent event is "message". I am trying to change the event name but it is not working. I am using Play 2.5 and akka streams. (actorRef,sourcePublisher)= Source .actorRef[T](10, OverflowStrategy.fail) .toMat(Sink.asPublisher(true))(Keep.both) .run() backsource = Source.fromPublisher[T](sourcePublisher).named("test1") Ok.chunked(backsource via EventSource.flow) .as(ContentTypes.EVENT_STREAM) But it is not changing the event name/type. It is still listening to

Play framework 2.5 - scala oauth2 provider issue

六月ゝ 毕业季﹏ 提交于 2019-12-12 03:26:39
问题 WHAT I DID: I am trying to implement oauth2 provider using Play framework. I am using the "scala-oauth2-provider" sample to do this. "https://github.com/nulab/scala-oauth2-provider" I have listed the version that I used in my application: Play -- 2.5 database -- Mysql 5.1.22 ISSUE: AuthCode.scala:19: could not find implicit value for parameter tm: scala.slick.ast.TypedType[org.joda.time.DateTime] [error] def createdAt = columnDateTime Code Snippet: import java.util.UUID import org.joda.time

Current Request/User details in Models in Scala Play! 2.5

喜欢而已 提交于 2019-12-11 13:39:46
问题 I would like to have access to the current user somewhere deep in my models of my Play app, for things like setting the author, checking that the user can actually save this type, etc. Ideally, what I would like to use is Guice's @RequestScoped to inject the same UserIdentity across my request, wherever I need it. However, as far as I can tell, the Play! Framework only supports @Singleton and no-scope. So either we'd get the same UserIdentity injected across requests or a different one for

Convert a JsValue to a model via Reads[T] which consists of a list of tuples

こ雲淡風輕ζ 提交于 2019-12-11 08:49:31
问题 I have the following class: case class Model(elements: List[(String, String)]) Now I want to fill my model Model with the values of a JsValue by using Reads[T] . The JSON could have different key values pairs which are unknown at the time of unmarshaling them and therefore I want to have them as a list of tuples. For example: { "foo": "bar", "barfoo": "foobar"} Should become: List(("foo" -> "bar"), ("barfoo" -> "foobar")) The problem is that I don't know how I can achieve a sort of wildcard

Play: How to prevent 404 on image src on first request after upload

我只是一个虾纸丫 提交于 2019-12-11 06:58:42
问题 I've got a simple form with 2 text and 1 file input @helper.form(action = routes.CharactersController.newCharacter(), 'enctype -> "multipart/form-data") { @helper.inputText(field = characterForm("characterName")) @helper.inputText(field = characterForm("characterRealName")) @helper.inputFile(field = characterForm("characterImage")) <p> <input type="submit"> </p> } in the newCharacter action I move the file to the asset folder. Http.MultipartFormData body = request().body().asMultipartFormData

How to make Playframework Evolutions logging more verbose?

笑着哭i 提交于 2019-12-11 06:08:00
问题 I've been trying to see what's going on with them, as I'm facing a problem. When I click the "apply this script" button, the page asking me to apply the script appears again, and it stucks in that loop. It creates the "play_evolutions" table, but no script is run. The log in the console doesn't give me any relevant info. I've run manually the script and it's ok... So I wan't to know what the real problem is, therefore I need more logging. 回答1: Evolutions are not very verbose in general (when

Play 2.5 Ebean and JPA: NoSuchMethodError

*爱你&永不变心* 提交于 2019-12-11 04:54:47
问题 Yet another issue I'm experiencing while migrating my projects to Play 2.5. One of the projects uses both Ebean and JPA. Here is build.sbt: name := "Project" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean) scalaVersion := "2.11.8" routesGenerator := StaticRoutesGenerator libraryDependencies ++= Seq( javaJdbc, javaJpa, "org.hibernate" % "hibernate-entitymanager" % "4.2.8.Final", cache, javaWs ) Everything was OK in Play 2.2.1. However, now I

formFactory.form() doesn't exist ! PlayFramework

那年仲夏 提交于 2019-12-10 15:35:53
问题 I've a little problem, i want to create a web app and i learn PlayFramework with java documentation of This sample code : public Result hello() { DynamicForm requestData = formFactory.form().bindFromRequest(); String firstname = requestData.get("firstname"); String lastname = requestData.get("lastname"); return ok("Hello " + firstname + " " + lastname); } The ''formFactory'' doesn't exist. http://i.imgur.com/W941Bgz.png Why I don't have this field ? And when i want to create a model, i don't