playframework-2.0

How to create a WSResponse object from string for Play WSClient

谁都会走 提交于 2020-07-20 10:53:09
问题 Documentation suggests testing API client based on WSClient using a mock web service, that is, create a play.server.Server which will respond to real HTTP requests. I would prefer to create WSResponse objects directly from files, complete with status line, header lines and body, without real TCP connections. That would require less dependencies and run faster. Also there may be other cases when this is useful. But I can't find a simple way to do it. It seems all implementations wrapped by

Stepping into JSON Arrays in Play Framework

帅比萌擦擦* 提交于 2020-02-28 00:34:03
问题 I am trying to parse through some json in the play framework from a remote http response. I am trying to get into results[0]->locations[0]->latLng->lat. I am using playframework 2.0 with scala. Below is the code I am using with a few commented examples of what i've tried so far. val promise = WS.url("http://www.mapquestapi.com/geocoding/v2/address?...").get() val body = promise.value.get.body val json = Json.parse(body) val maybeLat = (json \ "results" \ "0" \ "locations" \ "0" \ "latLng" \

Stepping into JSON Arrays in Play Framework

核能气质少年 提交于 2020-02-28 00:33:36
问题 I am trying to parse through some json in the play framework from a remote http response. I am trying to get into results[0]->locations[0]->latLng->lat. I am using playframework 2.0 with scala. Below is the code I am using with a few commented examples of what i've tried so far. val promise = WS.url("http://www.mapquestapi.com/geocoding/v2/address?...").get() val body = promise.value.get.body val json = Json.parse(body) val maybeLat = (json \ "results" \ "0" \ "locations" \ "0" \ "latLng" \

Source folder is not a Java project when working with Heroku eclipse plugin

随声附和 提交于 2020-02-23 07:38:09
问题 I have set up a new project and hooked it up with Heroku: I'm able to make changes and upload them to my dyno at Heroku but when trying to add new classes in eclipse I get **Source folder is not a Java project **. Have I missed anything? 回答1: Ok found it, needed to tell eclipse that this was a java project by adding: <natures> <nature> <name></name> </nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> So that the .project file look like this: <?xml version="1.0" encoding="UTF

Play doesn't convert java-list to scala-list

会有一股神秘感。 提交于 2020-02-07 03:44:08
问题 I have a controller which hands a java-list of model-objects to the view exactly the way like it's done in the examples. The compiler throws an error that it can't convert from java.util.List to scala.collection.immutable.List . I have no clue what I should do. [error] /myapp/myappsubprojects/frontend/app/controllers/frontend/MyController.java:15: error: method render in class linklist cannot be applied to given types; [error] return ok(linklist.render("link test", Link.findAll())); [error] ^

What is the difference between plugins, dependencies, modules and sub-projects in play 2.4?

筅森魡賤 提交于 2020-02-03 09:56:28
问题 I am new to the playframework and just learning.I am a little confused between dependencies, modules, plugins and sub-projects. How do they differ from each other? Here's what i have understood, i may be wrong. dependencies - are all the libraries needed for a play application to run. sub-project - is a play application inside another parent application. Not sure about 'plugin' and 'modules'. Can someone please explain how they differ? Note: I am working with Play 2.4 and play-java, not sure

What is the difference between plugins, dependencies, modules and sub-projects in play 2.4?

岁酱吖の 提交于 2020-02-03 09:55:22
问题 I am new to the playframework and just learning.I am a little confused between dependencies, modules, plugins and sub-projects. How do they differ from each other? Here's what i have understood, i may be wrong. dependencies - are all the libraries needed for a play application to run. sub-project - is a play application inside another parent application. Not sure about 'plugin' and 'modules'. Can someone please explain how they differ? Note: I am working with Play 2.4 and play-java, not sure

Scala Play Salat Aggregate Example

送分小仙女□ 提交于 2020-02-02 11:21:58
问题 I am using Scala Play 2.x with MongoDB in backend and I must confess that Salat has wonderful support for mongo CRUD operations. But so far I didn't find any good example of how I can call mongo aggregate function using SALAT like $unwind, $match, $group or aggregate pipeline. For example db.posts.aggregate([ { $unwind :"$tag" }, { $group : { _id :"$tags", count : {$sum :1} } }, { $sort : {$post :-1} }, { $limit :1 } ]) UPDATE (ALTERNATIVE) I didn't find any help which systematically explain