playframework-2.2

Handle chunked data sent by Play scala with AngularJs

南笙酒味 提交于 2019-12-03 13:48:42
问题 I send chunked data with Play Scala 2.2 to the client side like this : Ok.chunked(data) I would like to use them as soon as they are available on the client side. If I just get the data and print them on .success , they are printed at the same time i.e. when the last data is received. How can I print them as soon as they are received? Must I use websockets ? 回答1: Use streaming json library like http://oboejs.com/ Oboe.js is an open source Javascript library for loading JSON using streaming,

How to print @ symbol in HTML with play framework (scala)

自作多情 提交于 2019-12-03 13:46:44
I am new to Scala and play 2.1 and I come from a PHP background. I am not able to print the @ symbol in HTML. I am getting the following error: not found: value Hotmail Here is my code: myname<label>@Hotmail.com</label> Please let me know how I can print the @ symbol. Thanks in advance. Double it: myname<label>@@Hotmail.com</label> It's called escape syntax. Other rules for play template framework can be found here You can also write HTML Entity code &#64 for printing @ symbol in your view file. 来源: https://stackoverflow.com/questions/19157571/how-to-print-symbol-in-html-with-play-framework

Play 2.2 -Scala - How to chain Futures in Controller Action

最后都变了- 提交于 2019-12-03 13:42:56
问题 I have 3 futures of type Response. The first future returns a JsValue which defines if future 2 and future 3 shall be executed or only future 3 shall be executed. Pseudocode: If Future 1 then {future2 and future 3} else future 3 Iam trying to do this in a play framwork action which means in order to use the result of the futures later I cant use onSuccess, onFailure and onComplete because all of them return Unit and not the actual JsValue from the last future. I tried to do this with map()

Convert any Scala object to JSON

醉酒当歌 提交于 2019-12-03 08:53:56
问题 I am using latest version of Play Framework and it's JSON lib like this Json.toJson(obj) . But toJson is not capable of converting any Scala object to JSON, because the structure of data is unknown. Someone suggested using case convert, but here my Scala knowledge falls short. The data comes from database, but the structure of table is not known. Where should I look further to create convert such unknown data structure to JSON? 回答1: Given that there is only a limited number of types you want

Need advice on project layout for Play 2.2 submodule with other modules as dependencies

馋奶兔 提交于 2019-12-03 08:09:22
I have an existing SBT project with modules. I want to add Play 2.2 into my project as a submodule. This new Play module will depend on other modules. What I found so far was mostly about Play being the main project with supporting modules. If Play does support this setup, please point me in the right direction how to do it. Thanks. My intended setup (simplified): my_project \--- desktop_ui \--- src/main \--- src/test \--- common \--- src/main \--- src/test \--- web_ui (Play framework) \--- app/controllers \--- app/views \--- app/models \--- conf Two options: 1) have an 'empty' main project

Play 2.2 -Scala - How to chain Futures in Controller Action

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 04:42:22
I have 3 futures of type Response. The first future returns a JsValue which defines if future 2 and future 3 shall be executed or only future 3 shall be executed. Pseudocode: If Future 1 then {future2 and future 3} else future 3 Iam trying to do this in a play framwork action which means in order to use the result of the futures later I cant use onSuccess, onFailure and onComplete because all of them return Unit and not the actual JsValue from the last future. I tried to do this with map() and andThen but I am a Scala noob and I guess i wasn't able to do it because I always just missed a

Play framework routes, and scala predef values

纵饮孤独 提交于 2019-12-03 04:10:45
I develop application on play framework 2.2 I have a routes file like this: GET /posting/ controllers.posting.BlogController.allPosts() GET /posting/:number controllers.posting.BlogController.allPosts(number: Int) And BlogContriller: object BlogController extends Controller { def allPosts(pageNumber:Int = 1, postsPerPage:Int = 10) = Action{ val posts = Post.getLastNPosts(postsPerPage, postsPerPage*(pageNumber-1)) val htmlPosts = new Html(new StringBuilder()); for (post <- posts){ val htmlPost = views.html.posting.post(post.getName, post.getText, post.getDate.toString) htmlPosts += htmlPost; }

Handle chunked data sent by Play scala with AngularJs

时间秒杀一切 提交于 2019-12-03 03:46:41
I send chunked data with Play Scala 2.2 to the client side like this : Ok.chunked(data) I would like to use them as soon as they are available on the client side. If I just get the data and print them on .success , they are printed at the same time i.e. when the last data is received. How can I print them as soon as they are received? Must I use websockets ? Use streaming json library like http://oboejs.com/ Oboe.js is an open source Javascript library for loading JSON using streaming, combining the convenience of DOM with the speed and fluidity of SAX. It can parse any JSON as a stream, is

Convert any Scala object to JSON

做~自己de王妃 提交于 2019-12-02 22:48:16
I am using latest version of Play Framework and it's JSON lib like this Json.toJson(obj) . But toJson is not capable of converting any Scala object to JSON, because the structure of data is unknown. Someone suggested using case convert, but here my Scala knowledge falls short. The data comes from database, but the structure of table is not known. Where should I look further to create convert such unknown data structure to JSON? Given that there is only a limited number of types you want to serialize to JSON, this should work: object MyWriter { implicit val anyValWriter = Writes[Any] (a => a

Play 2.2.2 / com.typesafe.play#play_2.10;2.2.2: not found on Heroku

谁都会走 提交于 2019-12-02 06:32:12
All works well with Play 2.2.1. However, when upgrading to Play 2.2.2 and deploying to Heroku, process warns about: sbt.ResolveException: unresolved dependency: com.typesafe.play#play_2.10;2.2.2: not found unresolved dependency: com.typesafe.play#play-cache_2.10;2.2.2: not found unresolved dependency: com.typesafe.play#filters-helpers_2.10;2.2.2: not found unresolved dependency: com.typesafe.play#play-test_2.10;2.2.2: not found unresolved dependency: com.typesafe.play#play-docs_2.10;2.2.2: not found I don't figure out why..I just updated the plugins.sbt to: // Comment to get more information