playframework-2.0

RESTful http DELETE method in scala (play 2.0)

邮差的信 提交于 2020-01-02 09:37:10
问题 I am building app with Play 2.0. As far as Play form generator won't generate native http "Delete" request method, it should be replaced with either "Get" or "Post". @form(routes.Application.delete(id), 'class -> "topRight") { <input type="submit" value="Delete this computer" class="btn danger"> } According to Play examples "Post" should be used for "delete" purposes. Though using "Get" is much comfortable as form can be replaced with a simple link (especially having a list of those links on

java.lang.OutOfMemoryError: GC overhead limit exceeded on Scala

青春壹個敷衍的年華 提交于 2020-01-02 07:42:11
问题 I'M Scala developer,I am getting this error in a Routes file it contains 1008 lines if I add another Line that's throw given below error.. Uncaught error from thread [sbt-web-scheduler-1] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[sbt-web] java.lang.OutOfMemoryError: GC overhead limit exceeded at java.util.jar.Manifest$FastInputStream.<init>(Unknown Source) at java.util.jar.Manifest$FastInputStream.<init>(Unknown Source) at java.util.jar.Manifest.read

Auto-reloading with Play framework on a network filesystem

£可爱£侵袭症+ 提交于 2020-01-02 07:21:08
问题 I'm running a Play framework application on a VirtualBox VM with the project source code in a directory shared from the host system. The auto-reload functionality of the framework doesn't work. This is (probably) caused by JNotify being unable to detect the changes to the source files, as the filesystem is not local. Both NFS and vboxsf suffer from the same issue. Is there any way around this? Play framework has a built-in fallback mechanism for detecting changes on systems where JNotify is

Play Framework 2.4 Ebean Id Generation

99封情书 提交于 2020-01-02 06:57:22
问题 until now we have been using Play 2.3.9 and we are now migrating to Play 2.4.1 When I use the old version of Play saving an Entity works but with the new verion the Id is not generated. I setup a new project from scratch and tried it to realize it works and the auto generated database has an Id field that auto increments while the old project has a database that uses sequences. I have been trying to configure play/ebean to use sequences but have not been succesfull thus far. I took a look

play2 does not resolve messages when run from a unit test

a 夏天 提交于 2020-01-02 06:42:16
问题 I'm trying to run unit tests for the Play 2 based application, and we are having some issue regarding the Messages. Apparently, this one seams to not properly initialize or not initialized at all. @Test public void testMessage() throws IOException { running(fakeApplication(), new Runnable() { @Override public void run() { Locale.setDefault(new Locale("en")); String test = Messages.get("test.test"); System.out.println("DUMMY --" + test); } }); } The output of the above code is: "DUMMY -- test

Inserting multiple values into table with anorm

岁酱吖の 提交于 2020-01-02 05:54:07
问题 I want to insert multiple values into a table from a SQL query in Anorm. In the following snippet, is there a way to bind a list of usernames as values instead of just one username? SQL("insert into users (username) " + "values ({username})").on( 'username -> username, ).executeUpdate() As an alternative, I can create a concatenated string from my inputs, but that's prone to SQL injection and isn't quite as clean. 回答1: A possible way to insert multiple values at once, using Anorm: var fields:

Java Play 2 - How would you define a maxlength constraint from config parameter?

筅森魡賤 提交于 2020-01-01 19:34:10
问题 Using Play 2.3 (Java), I'd like to use a parameter from application.conf as a value for a constraint. Something like: public class Some { @Constraints.MaxLength(Play.application().configuration().getInt("some.text.maxlength", 1000)) public String text; } But of course I can't do this because the annotation parameter must be a constant. What would be the approach, in Java, to bypass this? Should I use a custom validator? Or is there another option? Any help appreciated. 回答1: As you discovered

Access translated i18n messages from Scala templates (Play! Internationalization)

限于喜欢 提交于 2020-01-01 19:05:20
问题 In my Play! 2.0 application I would like to define the following languages: # The application languages # ~~~~~ application.langs=en-GB,de-DE,nl-NL I also have created 3 files that ends with the corresponding language codes: Messages.en-GB Messages.de-DE Messages.nl-NL When I start the application without any request for a translated key I get the following error message: conf/application.conf: 12: Key 'de-DE' may not be followed by token: ',' (if you intended ',' to be part of the value for

Access translated i18n messages from Scala templates (Play! Internationalization)

拈花ヽ惹草 提交于 2020-01-01 19:05:19
问题 In my Play! 2.0 application I would like to define the following languages: # The application languages # ~~~~~ application.langs=en-GB,de-DE,nl-NL I also have created 3 files that ends with the corresponding language codes: Messages.en-GB Messages.de-DE Messages.nl-NL When I start the application without any request for a translated key I get the following error message: conf/application.conf: 12: Key 'de-DE' may not be followed by token: ',' (if you intended ',' to be part of the value for

custom Constraint in Play 2.0-scala?

拟墨画扇 提交于 2020-01-01 17:30:15
问题 I want to write a custom Constraint to use it in my Form for validation. Mappings in Form have a verifying function: verifying (constraints: Constraint[T]*): Mapping[T] . I can obviously use the built in constraints, e.g. "name" -> text.verifying(nonEmpty) . Now I need my own constraint though. The Constraint case class looks like: case class Constraint [-T] (name: Option[String], args: Seq[Any], f: (T) ⇒ ValidationResult) extends Product with Serializable But when I looked at