playframework-2.0

Comma separated list with Enumerator

可紊 提交于 2019-12-24 07:38:05
问题 I've just started working with Scala in my new project (Scala 2.10.3, Play2 2.2.1, Reactivemongo 0.10.0), and encountered a pretty standard use case, which is - stream all the users in MongoDB to the external client. After navigating Enumerator, Enumeratee API I have not found a solid solution for that, and so I solved this in following way: val users = collection.find(Json.obj()).cursor[User].enumerate(Integer.MAX_VALUE, false) var first:Boolean = true val indexedUsers = (users.map(u => { if

Map[Int, String] in Play framework template

痴心易碎 提交于 2019-12-24 05:53:15
问题 I'm using the Play 2.0.4 framework and I can successfully create a template that accepts a Map[String, String] template by putting this in the controller part: Map<String, String> test = new HashMap<String, String>(); return ok(views.html.template.render(test)); and in template.scala.html : @(map : Map[String, String]) However, if I change the first String to an Int (Integer in the controller part), I get this exception: error: method render in class template cannot be applied to given types;

What's the equivalent thing as ServletContextListener for Java

痴心易碎 提交于 2019-12-24 05:49:13
问题 I would ask what's the equivalent thing for Play as ServletContextListener for Java web. During the application starts up, I would fetch data from DB and save in memory/cache, and other things that is similar and suitable to be done during server startups In the Java web world, this is usually hooked into ServletContextListener#contextIntialized I searched stackoverflow,there were some answers there,but had been out dated 回答1: It's hard to give a complete answer without knowing exactly what

What's the equivalent thing as ServletContextListener for Java

怎甘沉沦 提交于 2019-12-24 05:49:05
问题 I would ask what's the equivalent thing for Play as ServletContextListener for Java web. During the application starts up, I would fetch data from DB and save in memory/cache, and other things that is similar and suitable to be done during server startups In the Java web world, this is usually hooked into ServletContextListener#contextIntialized I searched stackoverflow,there were some answers there,but had been out dated 回答1: It's hard to give a complete answer without knowing exactly what

Playframework 2 - set session variable for any Action

拟墨画扇 提交于 2019-12-24 05:34:05
问题 I need call method for all requests - i tryed object Global extends GlobalSettings { override def onRouteRequest(request: RequestHeader): Option[Handler] = { var test: String = request.session.get("test").getOrElse { request.session + ("test" -> "123") "000" } println(test) super.onRouteRequest(request) } } but I always see "000" in console and on page no cookies for domain Update: new cookies added by ResponseHeader, but how I can add new cookie to RH before RH created? Exists there

missing arguments for method apply… Play Framework 2.4 compilation error

柔情痞子 提交于 2019-12-24 05:30:43
问题 Compilation error: missing arguments for method apply in class newPost; follow this method with `_' if you want to treat it as a partially applied function I don't understand how template handling methods have to look like and what complier require of me. https://github.com/flatlizard/blog controller: def addPost = Action{ implicit request => Ok(views.html.newPost(postForm)) } def createPost = Action { implicit request => postForm.bindFromRequest.fold( hasErrors => BadRequest, success => {

foreign key query play! framework 2.+ ebean

倾然丶 夕夏残阳落幕 提交于 2019-12-24 04:47:07
问题 I'm new to play framework and the Ebean ORM. Basically, I have two models one is a RegUsers the other is RegIds . In my registration Ids I put a many to one relationship on the Field RegUsers . Stating, if I'm not mistaken that one user can have many registration ids. RegId model: @Entity public class RegId extends Model{ public static Finder<Long,RegId> finder = new Finder<Long,RegId>(Long.class, RegId.class); @Id public Long id; @ManyToOne public RegUsers regUsers; public String regId; }

PlayFramework, how to register a BeanPersistListener?

≯℡__Kan透↙ 提交于 2019-12-24 03:39:23
问题 I discovered the BeanPersistListener that I'd like to register to some of my models, but I didn't find any documentation, from Ebean nor PlayFramework on how to integrate it. From the documentation : A BeanPersistListener is either found automatically via class path search or can be added programmatically via ServerConfiguration.addEntity(). Apparently, it isn't found automatically (I added some Logger.info in the implemented methods, and nothing was shown), so I'd like to add it via

404 Not Found error when opening modal in Angular UI Boostrap

雨燕双飞 提交于 2019-12-24 03:24:04
问题 I have a really strange problem when using UI Bootstrap. Even the simplest example does not work. So this is my case: I have a Play Framework application using the yeoman plugin: https://github.com/tuplejump/play-yeoman. It is using AngularJS and Bootstrap. So far everything worked fine, but these weird errors came up when I tried to open my first modal using the UI Bootstrap library from http://angular-ui.github.io/. I used the exact code from http://angular-ui.github.io/bootstrap/#/modal

play framework 2.0 support memcached?

早过忘川 提交于 2019-12-24 02:16:32
问题 I read Play Framework 2.0 document,I don't any word about memcached.How can I use memcached in Play Framework 2.0? why disappear in 2.0, in 1.x ,it is so easy!!! 回答1: As already pointed out in the comments, the default implementation of the Cache API uses Ehcache. If you want to use memcached, you coult write your own Cache implementation, or you could use this one. 来源: https://stackoverflow.com/questions/9999204/play-framework-2-0-support-memcached