playframework-2.0

How can I render a simple html page using play framework?

百般思念 提交于 2020-02-01 04:57:24
问题 Is it a way to render a pure html file with play framework version 2? I don't want to put it in public/ folder because later on there will be some dynamic information added to it. 回答1: Here is my solution: in routes: I do some configurations as following. GET /hello.html controllers.Assets.at(path="/public/html", file="hello.html") GET /public/javascripts/jquery-1.9.0.min.js controllers.Assets.at(path="/public/javascripts", file="jquery-1.9.0.min.js") GET /public/stylesheets/bootstrap.css

Add <script> to the <head> from scala template tags in Play Framework 2

送分小仙女□ 提交于 2020-01-31 16:43:24
问题 I would like to add javascript to the <head> of my webpage from within tags. This is the moreScripts equivalent I'm using on my pages: main.scala.html @(title: String, scripts: Html = Html(""))(content: Html) <!DOCTYPE html> <html lang="nl"> <head> <title>@title</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> @scripts </head> <body> @content </body> </html> page.scala.html

Serializing a Scala List to JSON in Play2

冷暖自知 提交于 2020-01-28 04:30:25
问题 I am trying to deserialize a list of Scala objects to a JSON map in Play2 - a pretty trivial use case with JSON, I'd say. My JSON output would be something along the lines of: { "users": [ { "name": "Example 1", "age": 20 }, { "name": "Example 2", "age": 42 } ] } To achieve this I am looking at the Play2's JSON documentation titled "The Play JSON library" . To me their examples are pretty trivial, and I've confirmed that they work for me. Hence, I am able to deserialize a single User object

Serializing a Scala List to JSON in Play2

不羁的心 提交于 2020-01-28 04:30:13
问题 I am trying to deserialize a list of Scala objects to a JSON map in Play2 - a pretty trivial use case with JSON, I'd say. My JSON output would be something along the lines of: { "users": [ { "name": "Example 1", "age": 20 }, { "name": "Example 2", "age": 42 } ] } To achieve this I am looking at the Play2's JSON documentation titled "The Play JSON library" . To me their examples are pretty trivial, and I've confirmed that they work for me. Hence, I am able to deserialize a single User object

type is not a member of package controllers

六月ゝ 毕业季﹏ 提交于 2020-01-25 21:52:50
问题 I'm currently working on a web app with the play2 framework. Most of the time everything works fine. However when I decide to rebuild the project I get the error: "type HomeController is not a member of package controllers". I've done some research on the web and encountered discussions and topics about this error. However, on all of them this seems to be the answer: "Play 2.4, by default, generates a dependency injected router, unlike previously, when it used a static router. You have two

Heroku error 503, webSockets on multiple domains

谁都会走 提交于 2020-01-24 17:38:59
问题 I'm experiencing a 503 error with heroku on my project using WebSockets and a custom domain. Connecting on http://www.mydomain.com (That point with CNAME on my heroku app) WebSocket connection to 'ws://www.mydomain.com/shoutbox' failed: Error during WebSocket handshake: Unexpected response code: 503 Connecting on http://myapp.herokuapp.com Everything goes allright with adress ws://myapp.herokuapp.com/shoutbox . Everything is also good in my local setup. Is there any cross-domain issue I'm not

Heroku error 503, webSockets on multiple domains

这一生的挚爱 提交于 2020-01-24 17:38:04
问题 I'm experiencing a 503 error with heroku on my project using WebSockets and a custom domain. Connecting on http://www.mydomain.com (That point with CNAME on my heroku app) WebSocket connection to 'ws://www.mydomain.com/shoutbox' failed: Error during WebSocket handshake: Unexpected response code: 503 Connecting on http://myapp.herokuapp.com Everything goes allright with adress ws://myapp.herokuapp.com/shoutbox . Everything is also good in my local setup. Is there any cross-domain issue I'm not

Play Framework webservice tutorial scala [closed]

自作多情 提交于 2020-01-24 04:12:21
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm pretty new to Play! and scala and i'm searching desperatly for a good step by step tutorial on how to implement a webservice. the

multiselect select - Play 2.0?

烂漫一生 提交于 2020-01-23 08:39:30
问题 I am having big troubles get Multiselect to work with my Play 2.0 application. I have tried different solutions that I found on google, but none works for 2.0.1. Do you have any guides or tips for getting multi select to work ? The html... <select multiselect="multiselect" ... name="groupIds[]"> ... </select> The Form class UserAdminForm{ public Long[] groupIds; } and later in request handler... Form<UserAdminForm> form = uform.bindFromRequest(); // Bam , [NumberFormatException: For input

Routing overloaded functions in Play Framework 2.0

落花浮王杯 提交于 2020-01-23 08:35:14
问题 In Play, when overloading controller methods, those individual methods cant be routed more than once cause the complier doesn't like it. Is there a possible way to get around this? Say if I had two functions in my Product controller: getBy(String name) and getBy(long id) . And I had two different routes for these functions declared in routes : GET /p/:id controllers.Product.getBy(id: Long) GET /p/:name controllers.Product.getBy(name: String) I want to use the "same" function for different