save() and _save() model's methods in playframework

When create playramework's model we can use save() or _save() method. Why these both methods are avalible in the framework, what's the reason? (in this context they do the same - save object to db). Why I ask this: I have used save() method when doing some validation in it, but the end-user of my class could use _save() if he would want to save without validation. So I ask myself why there are two methods which are both public. I've handled it like this: The problem was with finding the pla

Playframework Play Framework routing with multiple parameters

I'm trying to setup a SEO friendly route in the Play! Framework that has multiple parameters (with the 2nd parameter being optional). What I'm aiming for is: http://domain.com/article/jsmith/name-of-article But what Play is generating is: http://domain.com/article/jsmith?articleSlug=name-of-article In my view: @{Article.show("jsmith","name-of-article")} My Controller public static void show(String username,String articleSlug){ ... } My routes file GET /article/{username}

Playframework Play framework asynch job compared to a Windows Service?

I have a windows service that checks an email account and then saves off an attached PDF that has a barcode in it. I read the barcode and route the PDF to an appropriate directory. The service runs every 5 minutes and has been working well. So my questions: Should I create Play Job for this? Do I constantly needs hits on the site to kick off the site? Would the job run at 2am when there's no hits? I am trying to learn what the limitations of the Jobs are and what the alternatives would be.

playframework external taglib

I'm trying to use an external library in view, ckeditor. that use sometinhg like this: <ckeditor:replace replace="editor1" basePath="/ckeditor/"/> but, html extension of playframework don't accept the taglib <%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %> and if I change the html extension for jsp the controller don't find his view Please, how can I use external taglibs?

Playframework Load data from file in Play framework YAML

I would like to load some data stored in a file into my mysql database when play is applying evolution to the database. Basically when play is running the 1.sql to upgrade the database, I would like to run a "LOAD DATA INFILE" or equivalent. Maybe there is an equivalent existing in yaml for LOAD DATA INFILE ? If yes, how could I achieve something similar to LOAD DATA INFILE "/path/to/myfile" INTO TABLE myTable FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'; Thanks

Playframework Play 2 async webservice call without using AsyncResult

Play 2 allows you to do async webservice calls through AsyncResult which won't block the thread: public static Result feedTitle(String feedUrl) { return async( WS.url(feedUrl).get().map( new Function<WS.Response, Result>() { public Result apply(WS.Response response) { return ok("Feed title:" + response.asJson().findPath("title")); } } ) ); } This only works if you're doing simple things l

Playframework SMTP Config in SecureSocial for live.com

I had configured my SecureSocial module in Play 2.0.4 for a SMTP email transfer. If I try my configuration with Gmail it works: smtp { host=smtp.gmail.com #port=25 ssl=true user="user@gmail.com" password="password" from="user@gmail.com" } But if I try it with live.com (they use the same port) it doesn't work?

Updating ManyToMany Checkboxes PlayFramework 2

I have some troubles to update Many-To-Many Relationship with checkboxes in Play Framework 2.1.0 Account Model: @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "account_security_role", joinColumns = { @JoinColumn(name = "account_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "security_role_id", referencedColumnName = "id") }) public List<SecurityRole> roles; I want to update account roles in account e

Playframework HTML5 appcache in play! framework

I am trying to use HTML5 application cache in play! framework to use my app for offline usage. But I am not finding steps to configure application cache manifest in play! framework. I am able to do this in apache tomcat. My requirement is , I will have few html pages with form fields which user should be able to see even play server is down.

Playframework Play Framework 2.2 TempoDB dependency

I need to access a TempoDB database in my Play2 app, using the java api https://github.com/tempodb/tempodb-java. I added the dependency in my build.sbt file : libraryDependencies ++= Seq( "com.tempodb" % "tempodb-java" % "0.7.0" ) I end up with the com.tempodb repository in play-2.2.1/repositories/cache/ , but that's it. It doesn't appear when I do play dependencies I tried every clean, reload, update you can imagine, it always fails to compile whenever I add an import com.tempodb.c

Playframework Error cannot start Play! app

When I try to run play app I get the following error (this didn't happen before): $ start 9010 [error] {file:/home/bogunovi/guesstiment/}guesstiment/compile:copy-resources: java.io.FileNotFoundException: /home/bogunovi/guesstiment/target/scala-2.9.1/classes/evolutions/default/1.sql (Permission denied) Oops, cannot start the server?

Playframework SBT plugin dependency resolution fails with com.typesafe.play#sbt-plugin;2.2.1: not found

I've a Play app and when I ran sbt, I got an error as follows: [warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/play/sbt-plugin/2.2.1/sbt-plugin-2.2.1.pom [info] Resolving org.fusesource.jansi#jansi;1.4 ... [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: com.typesafe.play#sbt-plugin;2.2.1: not found [warn] ::::::::::::::::::::::::::::::::::::::::::::::

Playframework in play 2.3.3, The entity must have get set?

in play 2.1.1 , entity Login.java: public class Login { @NotBlank(message = "login account cannot be empty") public String mobile; @NotBlank(message = "login password cannot be empty") public String password; public Integer ownInnId; public InnAdmin admin; public String token; } but in play 2.3.3 , post with error: play.api.Application$$anon$1: Execution exception[[IllegalStateException: JSR-30 3 validated property 'password' does not have a corresponding

Playframework Play Framework 2.3.7 Ebean OneToMany relationships not updated

I updated my project from play framework 2.1.x to 2.3.7. Now I have the following problem: If I use the Model.update() method, the OneToMany relationships will not be updated. Example below: @Entity @CacheStrategy public class Workshop extends Model { @Id public Long id; @OneToMany(cascade = CascadeType.ALL) public List<WorkshopWholesaler> wholesalers; } @Entity public class WorkshopWholesaler extends Model { @Id public Long id; @Column(nullable = false)

Playframework Change proxy settings in play framework

I was behind a proxy when I setup play framework. I edited the ~/.activator/activatorconfig.txt file and it worked fine. Now I need to remove that proxy to work on a different network. I commented out the line but the activator script still tries to use the proxy for connection, when I run ./activator new (or ./activator ui). The file currently looks like this # This are the proxy settings we use for activator # Multiple proxy hosts can be used by separating them with a '|' sign # Do not enclo

Playframework How to display form data in Play Framework

I created one Play application using forms. The code is shown in below. My requirement is i will set the form value in my Application controller in the index method. This value i need to display in index.scala.html username field. How to display username value in the form. index.scala.html @(login: model.com.ranga.Login) <!DOCTYPE html> <html> <head> <title>Login Form example</title> </head> <body> <div align="center" style='background: #80

Playframework Get application's root url with Play Framework

I'm using an Akka Scheduler to make a request to the root url of my Play Framework application every minute to refresh the application's cache if it expires. At the moment I am calling WS.url("http://127.0.0.1:9000/").get(); as I am working on my localhost. Obviously, when I push to production I will change this to request the production URL. Is there a function to obtain the root url automatically, so that I don't have to change this each time?

Playframework Play 2.5.4 - how to implement CSRF filters?

How does one implement CSRFfilters in Play 2.5.4? The play documentation is wrong (doesn't compile, and can't under the play 2.5.4 java api), the example here doesn't compile (Play 2.5 disable csrf protection for some requests). the 2.5 java API has a CRSFFilter class but it is not a sub class of EssentialFilter so cannot be added to the array of EssentialFilters because it is the wrong type. Is this functionality currently broken for Play 2.5.4 or is the documentation currently misleading/wro

Playframework Set "content Security Policy" dynamically in play 2.5

Play recommanded way to set the "content Security Policy" is to set the play.filters.headers.contentSecurityPolicy in the application.conf. But my requirement is to set this dynamically in the code by reading some custom entries in a override configuration file. Can some please suggest a way to set contentSecurityPolicy in Play programmatic by overriding the value play.filters.headers.contentSecurityPolicy in application.conf.

Playframework Controller method called synchronously

Take the default starter app for java and add the following to HomeController's index method: System.out.println("Before"); Thread.sleep(5000); System.out.println("After"); Then run a few tabs in a browser calling http://localhost:9000. The expected behavior is that Before is printed as soon as the request is issued from the browser tab. While the actual result is that consequent requests start executing only after the previous one has finished. Note that this is only observed when calling t

Playframework How to disable evolutions in play

I don't use evolutions and I want to disable it. I have used play.evolutions.enabled=falseand its working, the evolution table is not created, i don't get messages BUT I still have the evolution folder created every time, when I run the server it create evoltuon.default folder with 1.sql file in it. It's not running the file but I want to disable the creation of this folder. Any suggestions?

Playframework Action Chaining Not Redirecting After Controller.await(int millis)

I'm not sure if this isn't working as intended of it it's just me getting confused. What I would like to do is to asynchronously delay an action, and await(int millis) and I seem to be able to become friends. Here's what happens: 1. Application.index displays a form that sends a POST to Application.something. app/controllers/Application.java public static void index() { render(); } app/views/Application/index.html #{form @Application.something()} <input type="submit"> #{/fo

Playframework Crud module : Listing a OneToMany with a specific order

I'm using Crud module and I can make it work well. But when I displaying the form to add a new User (or edit an existing User), I have a list of Cities that are displayed in a non alphabetically way. I'd like to sort them based on the name. I tried to add a @OrderBy to my model, but this doesn't work. How can I do it? Thanks for your help! Here is my model for information : @Entity public class City extends Model { @Required @OrderBy //doesn't work public String nomination; //

Playframework Play framework multiple file upload

I try to upload multiple files with one request but it always error, My view code: <input type="file" name="files[]" multiple> And: public static void doUpload(File[] files) { File dir = new File(Play.applicationPath+File.separator+"public"+File.separator+"uploads"); if (!dir.exists()) { dir.mkdirs(); } boolean success = files.renameTo(new File(dir, files.getName())); if (!success) { renderText("{'success':'true', 'msg':{'url':'"+files.getName()+"'}

Playframework How do I change seed/database settings in PlayMorphia between dev and prod?

I have a Play Framework (1.2.4) project with PlayMorphia that has two different database connection profiles. One is for development and the other is for production, but I am only seeing one static looking config file hosting the values. I am reading on how this all works, but struggling on how to support two configuration settings. Is there some configuration trick in Play that people use?

ElementCollection Using With PlayFrameWork

I have some classes which are related. One them is have another classes's object set. Like this, @Entity public class Serving extends Model{ @Required public Item item; @Required public Float amount; @Required public Date time; public Serving(Item item, Float amount) { super(); this.item = item; this.amount = amount; this.time = new Date(); } } @Entity public class Receipt extends Model{ @Required @ElementCollection @NotNull public Set<Serving> servings; @Required

Playframework How to access models beyond the page scope in a template of Play! Framework?

In Play! template I tried to access some models as I did in JSP with beans, the template recognize the model class but when I tried to access the model property, it complained error: "MissingPropertyException : No such property" In my template: ${fulllyQualifyName.myModel} (a model not passed from controller) output on page: fulllyQualifyName.class ${fulllyQualifyName.myModel.propertyA} (try to get the propertyA) output on page: MissingPropertyException : No such property: propertyA for

Playframework: Strange behavior of "play start" - Caching issue?

I am currently developing a web app using play framework 2. I have created a folder "files" under /public directory. All the resources under that directory were accessible when I start the server using "play run". After deploy to the server. I started the server by running "play start" and found the resources under "files" cannot be found anymore. I am wondering what is the cause of the inconsistency between "play start" and "play run" UPDATE:After a few trial. I found that it's the newly up

Playframework how to navigate to default page rather than default error page by Play,when the request for a particular page is not available

In router file... GET /*file controllers.Assets.at(path="/public", file) So I am accessing the pages in public folder as shown below "192.168.2.7:9000/test.html" Problem: If the requested page is not existing (like test22.html) then play showing the default error page. But I want to navigate to default page like index.html, when the request page is not existing.

Playframework Play cannot resolve org.alfresco:alfresco-web-service-client dependency

I am new to Play Framework and have an application from which I need to access Alfresco. This is the Build.scala file object ApplicationBuild extends Build { val appName = "Librarian" val appVersion = "1.0-SNAPSHOT" val appDependencies = Seq( javaCore, javaJdbc, javaEbean, "org.alfresco" % "alfresco-web-service-client" % "4.2.c" ) val main = play.Project(appName, appVersion, appDependencies).settings( lessEntryPoints <<= baseDirectory(_ / "a

Playframework how to create an array and reuse in scala template play framework 2?

I need to create an array in one of my index.scala.html. Later I want to use that array to store some values. I want to achieve following index.scala.html @import scala._ @myArray = @{ArrayList()}; and I am getting an error saying not found value @myArray If above problem is resolved I want to reuser @myArray to add String values. How I can do that ? thanks

Playframework Separating Formbacking and Database backed Models . What is a valid approach

the last days i read many articles/comments/issues about everything related with the way the play examples suggest to structure a play app. The examples recommend to use the same Model/Class to back the Database AND Forms. But i have a problem with that. Form-Tampering and clutter code to handle updates(to just some fields of the model) from submitted forms... But when i search for solutions to those Problems, i often get to some github isues, where the play-core Team states, that people who ar

Playframework Monitoring BoneCP within a Play application

I'm trying to monitor BoneCP activities from a Play application. I have added the DB configurations in conf/application.conf db.default.disableJMX=false db.default.statisticsEnabled=true When starting the Play application I added the relevant flags to enable JMX as well -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=5678 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false Applicat

Playframework NullPointerException: null in Play Framework 2.3.1

Actually im going to migrate play framework 2.0.8 in 2.3.1 and have adjusted the corresponding changes. This Error leave me in the shadow, when i run the code: NullPointerException: null No source available, here is the exception stack trace: java.lang.NullPointerException: akka.actor.IndirectActorProducer$.apply(Props.scala:305) akka.actor.Props.producer(Props.scala:173) akka.actor.Props.<init>(Props.scala:186) Global.onStart(Global.java:105) play.core.j.JavaGlobalSetti

Playframework Play Framework sbt-concat does not work with wildcard setting

I was trying to bundle all css under a directory and its sub-directories. However, I found that only the files under direct level of the specified directory would be bundled, but not the ones in sub-directories. Then, I tried something like this to indicate that it is for everything including "lib.css" -> group(((sourceDirectory in Assets).value / "css" / "core" / "lib") * "**/*.css") This is not working for me. I opened up an issue in github already and I hope it will be fixed soon. However

Playframework Play Framework - issues with RequireJS optimizer

I have a PlayFramework 2.3 project and using require.js on the client side. When I run activator run everything works fine (so I'm sure the dependencies of require are ok). But when running activator start, some of the dependencies are missing. In the play documentation (here) they say: The RequireJS optimizer shouldn’t generally kick-in until it is time to perform a deployment i.e. by running the start, stage or dist tasks. So the optimizer runs when running start and doesn't run wh

Playframework Play! Framework templates parameter groups

I've been reading the documentation on the Play! website and can't see where it explains what parameter groups are and what they would be used for. What is the difference between: @(title: String)(user: User) And: @(title: String, user: User) If someone could help me out here it'd be greatly appreciated.

Playframework self-type does not conform error with play2reactivemongo

I met the following error after upgrading play2reactivemongo to 0.11.0.play24. The code compiles fine before the upgrade. Code: object TestController extends Controller with MongoController with CookieLang{ Error Message: self-type controllers.TestController.type does not conform to play.modules.reactivemongo.MongoController's selftype play.modules.reactivemongo.MongoController with play.api.mvc.Controller with play.modules.reactivemongo.ReactiveMongoComponents

Playframework Getting Current Time For FixedWindowRollingPolicy in Play Framework Logging

I want to hold up to 20 log files, where I rollback when a file reaches a certain size. The catch is - when I archive a file I want to to have the current time in its' name. Currently I use: <timestamp key="bySecond" datePattern="ddMMyyyy'-'HHmmss" timeReference="contextBirth"/> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${application.home}/logs/log.txt</file> <append>true</append> &l

Playframework Getting AWS error while creating new play project (activator)

I am trying to develop a sample play framework applicaiton but when I have downloaded it and tried executing it I am getting below error related to amazon cloud web services(AWS). java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials Command I am executing : activator new my-first-app play-java I have downloaded activator-1.3.7-minimal and it has only 3 files : activator activator.bat activator-launch-1.3.7.jar I am wondering why it is trying to get AWS.

Playframework How to set up Play 2.4 with slick and liquibase + postgresql

I'm starting a small personal project in play framework 2.4 I want to use slick 3 and liquibase for handling db queries na db schema management. Right at the start i faced some issues in configuration. In nutshell. I created simple app from activator(play-scala seed). I added slick to the project. I tried to connect liquibase to my application accordingly to instruction: https://github.com/Ticketfly/play-liquibase I added two files: <!-- conf/liquibase/changelog.xml --> <?xml vers

I am creating simple web application using playframework 2.5.4 UNRESOLVED DEPENDENCIES error

I have project structure as below as per Migration Document and New application Document for playframework 2.5.4. plugins.sbt with: resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" // Use the Play sbt plugin for Play projects addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.4") build.sbt with: name := """ProjectNameWebProxy""" version := "1.0" lazy val root = (project in file(".")).enablePlugins(PlayJava) But following dependencies not found

Playframework Need of sbt-digest in play framework

What is the significance of using the sbt-digest plugin in play when it is mentioned in play's documentation that it can generate etags using the resource last modified date and the resource name, if sbt-digest is not being used.Are there benefits other than etags, for which one should use the sbt-digest plugin ? Reference : - https://www.playframework.com/documentation/2.4.x/Assets#etag-support

Playframework How to use Messages via Dependency Injection in a Play Framework 2.6 app?

I'm migrating a Play web app to v2.6 and I'm having trouble understanding how dependency injection works with Messages considering that Messages are dependent on the HTTP context of the request. I added a field injection to a controller like this: public class MyController extends Controller { @Inject private Messages m; public Result all(String uuid){ // using m.at("xxxxxx") } } And I've got something like this: play.api.UnexpectedException: Unexpected exception[Pro

Playframework Play Framework PUT Request Fails

I am using Play Framework 2.2.3 to create a RESTful API and have some trouble with my tests. I am running a TestServer to test all the routes. There's this weird problem that I suspect to be a bug. All PUT requests with a JSON payload to a route always fails. FakeRequest fakeRequest = new FakeRequest(httpMethod, route); if (jsonBody != null) { fakeRequest.withJsonBody(jsonBody); } Result result = route(fakeRequest); // <== result is 'null' for PUT with JSON body assertEquals(status,

  1    2   3   4   5   6  ... 下一页 最后一页 共 13 页