playframework-2.1

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

Java + Play Framework 2 with nested action compositions in the same class

你离开我真会死。 提交于 2020-01-15 09:09:10
问题 I was looking how to implement a filter in Play Framework 2 and, for the best of my knowledge, the best approach is to implement that using action composition. That said, I started doing some testing and I was able to make that to work. The only limitation is when I have nested annotations in the same class. My current use case Perform domain validation when domain parameter is present in the request. If the domain is not present in the local database, perform syntax validation only.

Dynamic Javascript using Scala template

旧城冷巷雨未停 提交于 2020-01-13 20:21:42
问题 I am trying to localize my Javascript files. For instance, I would have: var count = 0; $('#choices .choice').each(function(i) { $('input', this).each(function() { count++ $(this).attr('placeholder', '@Message("placeholder.choice") ' + count) }) }) This would obviously work if the Javascript file is inside the Scala HTML template but I would prefer to have it in a dedicated file. To begin with, I am wondering if it is a good idea: what about caching file if it's content may change? In this

What are the differences between Play run and start?

别来无恙 提交于 2020-01-13 09:03:27
问题 I would like to understand the differences between running play start and play run, in the context of the problem below. My specific use case is rather complex, but I'll simplify it like this: On startup (as part of Global.scala), my Play application is making a direct method call to the entry point of a Java application X. As part of its initialization, X starts an embedded instance of Tomcat. At the end of X's initialization, it verifies that Tomcat is up and responding to requests. Now,

type mismatch error when creating Reads for Play 2.1

混江龙づ霸主 提交于 2020-01-11 11:15:10
问题 I have been playing with this for hours. I have been trying different methods of creating a read and I am just completely stumped. I am on Play 2.1.0 and Scala 2.10.1 ERROR: type mismatch; found : models.Registration.type required: play.api.libs.json.Reads[?] Code: package models import play.api.libs.json._ import play.api.libs.functional.syntax._ case class Registration( user: (String,String,String,String,String,String) ) object RegistrationHelper { implicit val regReads: Reads[Registration]

How do I configure Logback to print out the class name

无人久伴 提交于 2020-01-09 10:37:52
问题 I'm using Play 2.1. I'm using the default logger play.api.Logger. I'm confused about how it works. In my scala code, a line in class "com.myapp.tickets" in the method "getPayment()" like this Logger.info("getTickets") generates a log message like this. 14:58:58.005 INFO application play.api.LoggerLike$class info getTickets My application-logger.xml pattern is %d{HH:mm:ss.SSS} %-5level %logger %class %method %msg%n The issue I have is that %logger tells me "application", %class tells me "play

play framework 2.1.x test conflict with slf4j-api

狂风中的少年 提交于 2020-01-06 01:31:53
问题 i've got a Play Framework 2.1.0 application, and even the simplest unit test will not run due to a system problem i'm struggling to track down. given this route: POST /foo/bar controllers.FooBar.test() ...i've got a simple test to verify that the route exists: @Test public void fooBarRouteExists() { running(fakeApplication(fakeGlobal()), new Runnable() { @Override public void run() { final Result result = route(fakeRequest(POST, "/foo/bar")); assertThat(result).isNotNull(); } }); } ...which

play framework 2.1.x test conflict with slf4j-api

和自甴很熟 提交于 2020-01-06 01:31:30
问题 i've got a Play Framework 2.1.0 application, and even the simplest unit test will not run due to a system problem i'm struggling to track down. given this route: POST /foo/bar controllers.FooBar.test() ...i've got a simple test to verify that the route exists: @Test public void fooBarRouteExists() { running(fakeApplication(fakeGlobal()), new Runnable() { @Override public void run() { final Result result = route(fakeRequest(POST, "/foo/bar")); assertThat(result).isNotNull(); } }); } ...which

Playframework 2.1 and Heroku update problems

我是研究僧i 提交于 2020-01-05 10:13:32
问题 i've create a play framework 2.1.0 project and deployed it on heroku. Last friday I've had to change the data models to add some extra fields. Once i tried to deploy the changes, it gave me evolution errors. Unable to fixe the problem i've reverted the changed and deployed the old version but i still get an error. The current error i'm getting is this database [default] connected at jdbc:postgresql: ... Position: 27 [ERROR:0, SQLSTATE:42601] ERROR: syntax error at or near "FALSE" at play.api

Compilation error when testing non blocking Redis client (Fyrie) on Play Framework 2.1

白昼怎懂夜的黑 提交于 2020-01-05 08:07:51
问题 when I try to compile the following code import play.api._ import play.api.mvc._ import scala.collection.mutable.StringBuilder import net.fyrie.redis.RedisClient import net.fyrie.redis.RedisClientConfig //import akka.dispatch._ //import akka.dispatch.Future object Application extends Controller { // val rd: RedisClient = new RedisClient("localhost", 6379, new RedisClientConfig(1, true, true, 50 to 100))(akka.actor.ActorSystem.create) val rd = RedisClient.apply("localhost", 6379, new