playframework-2.0

Changing Guice bindings at runtime

我只是一个虾纸丫 提交于 2019-12-19 05:24:14
问题 I would like to be able to change the Guice injections at runtime to support multiple injections based on user input. This is what I would like to achieve: public interface IDao { public int someMethod(); } public class DaoEarth implements IDao { @Override public int someMethod(){ ... } } public class DaoMars implements IDao { @Override public int someMethod(){ ... } } public class MyClass { @Inject private IDao myDao; public int myMethod(String domain) { //If Domain == Earth, myDao should be

Broadcasting messages in Play Framework WebSockets

◇◆丶佛笑我妖孽 提交于 2019-12-19 04:37:00
问题 I'm pushing messages in Play Framework WebSockets using Concurrent.unicast[JsValue] , and I want to optimize sending the same message to multiple users. Is it possible to broadcast message using somehow multiple Concurrent.Channel ? 回答1: Short answer Maintain separate channel for each user and have groups associated with users Long answer package controllers import akka.actor.Actor import play.api.libs.iteratee.Enumerator import play.api.libs.iteratee.Concurrent.Channel import play.api.libs

Broadcasting messages in Play Framework WebSockets

走远了吗. 提交于 2019-12-19 04:36:14
问题 I'm pushing messages in Play Framework WebSockets using Concurrent.unicast[JsValue] , and I want to optimize sending the same message to multiple users. Is it possible to broadcast message using somehow multiple Concurrent.Channel ? 回答1: Short answer Maintain separate channel for each user and have groups associated with users Long answer package controllers import akka.actor.Actor import play.api.libs.iteratee.Enumerator import play.api.libs.iteratee.Concurrent.Channel import play.api.libs

Play! 2.0 framework multi Module project

拈花ヽ惹草 提交于 2019-12-19 03:59:40
问题 I would need to have two different projects, let's say internal and external, which use the same data layer, and I would like to avoid replicating the configuration file for dryness reasons. I have looked to the sub projects documentation at http://www.playframework.org/documentation/2.0.2/SBTSubProjects but the doc is pretty short. I am now aware of the possibility to modularize the configuration, thanks to @Georg Engel import sbt._ import Keys._ import PlayProject._ object ApplicationBuild

When should I make methods with implicit argument in Scala?

被刻印的时光 ゝ 提交于 2019-12-19 03:37:14
问题 I made codes using play framework in scala which look like the following: object Application extends Controller { def hoge = Action( implicit request => val username = MyCookie.getName.get Ok("hello " + username) } } object MyCookie { def getName( implicit request: RequestHeader ) = { request.cookies.get("name").map(_.value) } } I got a code review from my coworker. He said this code is not readable because of implicit parameter. I couldn't reply to his opinion. So could you tell me what is

How to do “OR” filter in slick

老子叫甜甜 提交于 2019-12-18 19:44:40
问题 In slick we can use query.filter( m => (m.state === state1 && m.status === status1) || (m.state === state2 && m.status == status2)) for an "OR" condition in where clause. However my requirement is I have "OR" conditions in a list (passed by user as part of URL). Conditions list includes tuples of state and status like List[(state1, status1),(state2, status2),(state3, status3)] So what I wanted was to either be able to build the || statement inside of filter so that I can use each of the

assign null default value for optional query param in route - Play Framework

两盒软妹~` 提交于 2019-12-18 19:31:15
问题 I'm trying to define an optional query parameter that will map to a Long , but will be null when it is not present in the URL: GET /foo controller.Foo.index(id: Long ?= null) ... and I essentially want to check if it was passed in or not: public static Result index(Long id) { if (id == null) {...} ... } However, I'm getting a compilation error: type mismatch; found : Null(null) required: Long Note that implicit conversions are not applicable because they are ambiguous: both method

Play! framework 2.0: How to display multiple image?

ぃ、小莉子 提交于 2019-12-18 17:29:43
问题 I need to display a gallery of photos. So here is my template: @(photos: List[Photo]) @title = { <bold>Gallery</bold> } @main(title,"photo"){ <ul class="thumbnails"> @for(photo <- photos) { <li class="span3"> <a href="#" class="thumbnail"> <img src="@photo.path" alt=""> </a> </li> } </ul> } And here is my controller method: public static Result getPhotos() { return ok(views.html.photo.gallery.render(Photo.get())); } And here is my Photo bean : @Entity public class Photo extends Model { @Id

Ebean Query by OneToMany Relationship

牧云@^-^@ 提交于 2019-12-18 17:26:38
问题 I'm using Ebean with the Play 2 Framework and got two models: a user model and a book model. The user model is connected with the book model in a OneToMany Relationship. So every user can have many books or no book at all. The book model itself has properties too. Now I want to create a query in the user model, which returns only users, who have books with certain properties. For example: One property might be condition, like new or used. Now give me all users which have books in new

playframework - IOException unable to allocate memory

不打扰是莪最后的温柔 提交于 2019-12-18 15:43:09
问题 My system is Mint 12 64bit. I've installed the typesafe stack and created a new play application. Without modifying the code I've tried to run it. This is the output: http://pastebin.com/6XwmsbAE Play complains with this error message: IOException: Cannot run program "javac": java.io.IOException: error=12, Cannot allocate memory How can I fix this ? UPDATE: @Mef Ok you were definitely right. I've increased the initial RAM from 1 GB to 2 GB (running this on virtualbox). Compiling worked