playframework-2.1

Is there default catch all route to new actions in Play 2?

老子叫甜甜 提交于 2019-12-10 02:21:17
问题 In Play 1, new actions you defined had a default route. * /{controller}/{action} {controller}.{action} (This appeared by default in new projects) What is the Play 2/2.1 equivalent? Why doesn't it appear in the default routes file? 回答1: Actually there is a catch-all route available. According to the routing doc in Play 2.0+ you can use Dynamic parts spanning several / so if you put it as exactly last route of given method it will catch every route that wasn't catch before. You can use this for

IllegalStateException: impossible to get artifacts when data has not been loaded for Guava 12.0?

醉酒当歌 提交于 2019-12-09 07:33:17
问题 In a Java Play 2.1.1 app I get the following error: [myproject] $ update [info] Updating {file:/C:/path/myproject/}myproject... [info] Resolving ... [error] impossible to get artifacts when data has not been loaded. IvyNode = com.google.guava#guava;12.0 [error] (*:update) java.lang.IllegalStateException: impossible to get artifacts when data has not been loaded. IvyNode = com.google.guava#guava;12.0 [error] Total time: 230 s, completed 17.05.2013 19:16:41 Build.scala "com.google.guava" %

Connect “computer-database-jpa” Play 2.1 sample application with MySQL

孤街浪徒 提交于 2019-12-08 23:37:27
问题 I'm playing with computer-database-jpa (Java) Play Framework 2.1 sample application. Everything works fine when I'm using H2 in memory database but I had problems when I want to connect the application with MySQL. Some one had the same problem (Help wanted getting sample app connected to MySQL) but there was no solution. I've added mysql-connector (Build.scala): val appDependencies = Seq( .... "mysql" % "mysql-connector-java" % "5.1.18" ) and edited application.conf: db.default.url="jdbc

How do I create a function in PostgreSQL using evolutions in the Play framework?

我们两清 提交于 2019-12-08 16:21:12
问题 With the Play Framework 2.1 I have the following SQL defined in my evolution: CREATE OR REPLACE FUNCTION idx(myArray anyarray, myElement anyelement) RETURNS int AS $$ SELECT i FROM ( SELECT generate_series(array_lower(myArray,1),array_upper(myArray,1)) ) g(i) WHERE myArray[i] = anyElement LIMIT 1; $$ LANGUAGE sql IMMUTABLE; When I execute the evolution, I get the following error: We got the following error: ERROR: unterminated dollar-quoted string at or near "$$ SELECT i FROM ( SELECT

Play framework select input validation

旧街凉风 提交于 2019-12-08 10:37:49
问题 I am using Play 2.1 I made a select drop down box using the helper field constructor. The drop down box have 3 fields, default:"choose a gender", Male, and Female. How do I ensure that the user choose one of male or female, and not the default value? (A required drop down field) 回答1: I am using Play!Framework 2.1.0 , below is a simple solution for your problem: The model should be like this: (Below is simple model for your problem) package models; import play.data.validation.Constraints;

play2-elasticsearch example is not working with play2.1.3

旧时模样 提交于 2019-12-08 06:56:43
问题 I'm trying to use play2-elasticsearch plugin for playframework2 version 2.1.3 I have just done exactly the github example says, the only modification was to change this line to use the server on the local ip address. elasticsearch.client="127.0.0.1:9300" but when i try to run the example i get the following exception, any idea? I'm using play framework 2.1.3 on mac with jdk1.7 play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.ExceptionInInitializerError]] at play

play framework 2.1.3 extend play.api.templates.Html

依然范特西╮ 提交于 2019-12-08 03:41:42
问题 Just wondering if it's possible and if yes how hard it is to extend the play.api.templates.Html class. import java.lang.StringBuilder; public class MyHtml extends play.api.templates.Html { } gives me the error: error: constructor Html in class Html cannot be applied to given types; this gives the same: public class MyHtml extends play.api.templates.Html { String text; public MyHtml(String text) { this.text = text; } } Thank you 回答1: play.api.templates.Html is written in Scala not Java, so it

Play2 and Anorm, how do I make the One in a One to Many relationship aware of it's Manys

孤者浪人 提交于 2019-12-08 02:21:49
问题 I have a one to many relationship between User and LinkedAccount, a User can have several linked accounts. I have no problem in loading a LinkedAccount and it's User by doing: LinkedAccount(id, provider_user_id, salt, provider_id, auth_method, avatar_url, User.findBy(user)) in the parser. What I can't figure out is how load a user with it's LinkedAccounts. I guess I need to make the user aware of the LinkedAccounts.. but how? I would like to this to get rid of one extra sql call to the db

Play Framework 2.1 Remove a core dependency

谁都会走 提交于 2019-12-08 01:57:06
问题 since a few day now i'm trying to use Joda-time 1.6.2 on a play project. I know the play framework already come with the Joda-time 2.1 and it should be compatible with 1.6.2 according to joda-time site. I'm trying to write an application that ask the user for a LocalDateTime and save the class with the attributes on a MongoDB using morphia. I'm facing a problem, i have to use a class that are currently using joda-time 1.6.2 and i cannot change it dependency neither update it to 2.1. Since i

Change language of text in template in play framework 2.1.1

夙愿已清 提交于 2019-12-08 01:36:26
问题 I want the user of the application can change the language in my play2 (play 2.1.1, scala 2.10.1) web application. I use @Messages.get(...) in my templates for i18n. I have application.langs="en,ru" in application.conf. I pass "en" or "ru" to that method: def index = Action { Ok(views.html.index()) } def changeLanguage(lang:String) = Action { implicit request => Logger.logger.debug("Change user lang to : " + lang) val referrer = request.headers.get(REFERER).getOrElse(HOME_URL) Redirect