playframework-2.1

Execution exceptionAskTimeoutException: Timed out playframework

纵饮孤独 提交于 2019-12-11 20:32:32
问题 I'm calling a method from Ajax... and PlayFramework 2.1.3 $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", url: "/examplefoo", data: JSON.stringify(exampleArray), success: function(data) { doSomething(); }, error: function(e) { console.log(e); } }); On Application.java I call a method that does a huge computation and this spend a lot of time... @BodyParser.Of(play.mvc.BodyParser.Json.class) public static Result examplefoo() throws SQLException,

Play 2.1 / taking in account a javaagent while running tests

人走茶凉 提交于 2019-12-11 12:08:40
问题 My goal is to launch my integration tests contained within my Play app. To do so, I used to launch them through Intellij. Those tests needs Spring aspectJ weaving, thus I precised in my Intellij test conf this VM argument: -javaagent:/Users/myName/.ivy2/cache/org.springframework/spring-instrument/jars/spring-instrument-3.2.2.RELEASE.jar The whole works. Now I want to be able to launch them through command-line using the simple play command following by test-only command. First I read this

play2 using main project views/controllers/models in submodule/subproject and inversely

不问归期 提交于 2019-12-11 11:25:54
问题 I have: main project sub project called "shopping" I would like to use views from main project inside the subproject. My code of sub project controller: package controllers.shopping; public class Application extends Controller { public static Result index() { return ok(views.html.confirmation.render("ok")); } } And my main build file lazy val shopping = project.in(file("modules/shopping")) val main = project.in(file(".")) .dependsOn(shopping).aggregate(shopping) My model class in submodule

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

How to implement a new guice scope that caches and return named instances?

纵饮孤独 提交于 2019-12-11 08:56:19
问题 I want to be able to connect to various back-ends by changing a custom header of my HTTP requests. Therefore I want that my request is served with a controller instance that is specific to the selected back-end. The controllers that serve the requests are created using Guice and have many dependencies. I want to cache these controller instances. So for each (SomeController.class, backend) pair there would be a cached instance. How to implement such a Guice scope? I am using Play Framework 2.1

how to generate option values in Playframework Form helper @select

邮差的信 提交于 2019-12-11 06:57:39
问题 i want to generate a <select> tag in Play Form . but the option values are not fixed. so i coded it as this: @select( myF("server_id"), options( for(s <- servers){s.getId -> s.getName} ) ) however, the compiler tells out that: Overloaded method value [apply] cannot be applied to (Unit) cannot i use for sub in option ? and how should i code? thx. 回答1: @select takes a sequence of (String, String) tuples. You already have a sequence ( servers ), so you just to map them to tuples: @select( myF(

Bind complex (JSON) form data automatically

只谈情不闲聊 提交于 2019-12-10 13:18:05
问题 My JSON data coming in request().body().asFormUrlEncoded().get("records") [{"string":"foo","termId":"793340"},{"string":"bar","termId":"460288"}] My form definition: public static class MyForm { @Constraints.Required public List<Map<String,String>> records; public String someField; } It doesn't bind the records automatically. Then I tried with a POJO instead: public static class Record { public String string; public String termId; public void setString(String string) { this.string = string; }

play framework - securesocial userpass implementation

青春壹個敷衍的年華 提交于 2019-12-10 12:14:15
问题 I'm using Play 2.1 and securesocial master snapshot. I've implemented find & save of UserService (extends UserServicePlugin) as follows: Find method as below: def find(userId: UserId): Option[Identity] = { val user = User.findByUserId(userId); user match { case Some(user) => { val socialUser = new SocialUser(userId, null, null, user.name, Option(user.email), Option(user.photo), AuthenticationMethod("userPassword"), null, null, Some(PasswordInfo(PasswordHasher.BCryptHasher, BCrypt.hashpw(user

Update the Task model - RuntimeException: DataSource user is null?

北战南征 提交于 2019-12-10 10:37:54
问题 I started learning Play framework today and it is very good and easy to learn. I successfully completed the sample provided on their website, but I wanted to make some modifications to it. I wanted to see if could update the label of a particular task, so I followed the following approach First I added a route to update the data POST /tasks/:id/update controllers.Application.updateTask(id: Long) Then I added the following code to index.scala.html file @form(routes.Application.updateTask(task

Play 2.0/2.1 for Java and dependency injection

我是研究僧i 提交于 2019-12-10 03:17:04
问题 We have a new Play 2.0 project and we are planning to introduce DI as we add some complex 3rd party integration code. There is a Guice plugin for Play 2.0 but it looks like it will be obsolete at 2.1 and I have a hunch that 2.1 is not that far anymore. https://github.com/typesafehub/play-plugins/tree/master/guice Is Guice a safe bet for Play 2.0/2.1 or should we consider other options? 回答1: I'd go with the 2.1 version, and the new controller instanciation from the Global object. Here is a