playframework

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

play framework 2: saving many to many

纵饮孤独 提交于 2020-01-31 18:18:05
问题 I'm new to Play Framework 2. I have 2 models: Book and Author, one book can have many authors, so I think its many to many. Here are my models: @Entity public class Book extends Model { @Id public Long id; @Constraints.Required public String title; @Constraints.Required @ManyToMany(cascade=CascadeType.ALL,mappedBy="books") public Set<Author> authors = new HashSet<Author>(); public static Model.Finder<Long,Book> find = new Model.Finder<Long,Book>(Long.class, Book.class); public static Page

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

PlayFramework resolves dependencies every launch

南楼画角 提交于 2020-01-25 04:30:27
问题 Every time I launch my app play resolves dependencies. Considering this happens every single launch takes a lot of time... There was a time I had problem with one lib that wasn't unavailable so the app didn't launch... Is there anyway to configure play/SBT to work like Maven? Download dependencies and use local instead resolve every launch? 回答1: Yes, you can do this. Add skip in update := true in to the build.sbt file to stop dependencies resolution. My build.sbt looks like ... scalaVersion :

How make a Singleton across all ClassLoaders?

 ̄綄美尐妖づ 提交于 2020-01-25 04:11:25
问题 I've tried all the suggested solutions including: http://snehaprashant.blogspot.com/2009/01/singleton-pattern-in-java.html How to create a JVM-global Singleton? But none of these seem to work. They either are not truly Singletons across all ClassLoaders (the first link above) and result in different instances on application reload (I'm using Play Framework 1.3.x which reloads classes upon code change and recompile), or they require the classes to be on the System classpath. Is there a

Akka dispatcher not configured exception in Play/Scala application

非 Y 不嫁゛ 提交于 2020-01-24 20:58:26
问题 I am doing a disk intensive operation and I want to use my own thread-pool for it and not the default one. I read the following link, and I am facing the exact same problem Akka :: dispatcher [%name%] not configured, using default-dispatcher But my config file is slightly different, I have tried the suggestion but it not working. My application.conf in play has the following jpa-execution-context { thread-pool-executor { core-pool-size-factor = 10.0 core-pool-size-max = 10 } } And then in my

Akka dispatcher not configured exception in Play/Scala application

狂风中的少年 提交于 2020-01-24 20:57:59
问题 I am doing a disk intensive operation and I want to use my own thread-pool for it and not the default one. I read the following link, and I am facing the exact same problem Akka :: dispatcher [%name%] not configured, using default-dispatcher But my config file is slightly different, I have tried the suggestion but it not working. My application.conf in play has the following jpa-execution-context { thread-pool-executor { core-pool-size-factor = 10.0 core-pool-size-max = 10 } } And then in my

To deploy Play Framework apps in AWS (Amazon) ec2 using Ansible playbook

荒凉一梦 提交于 2020-01-24 20:15:12
问题 I am very new to AWS ec2 platform. I wanted to deploy my play 2.* app in the ec2. Also I need to deploy it through git in future update. I have done a decent research on it and found Ansible playbook could be a better solution to this. But I am using windows and configured it with ec2 using putty. Now I know very less about command line programming and Ansible and Ansible playbook . I need some help to find the solution for play to run in ec2 throug git directly. I am sharing some interesting