playframework-2.3

How to write a Play JSON writes converter for a case class with a single nullable member

二次信任 提交于 2019-12-18 11:56:51
问题 In Play 2.3, I have a case class with a single optional double member: case class SomeClass(foo: Option[Double]) I need a JSON write converter that handles the member as nullable: implicit val someClassWrite: Writes[SomeClass] = ??? The Play docs provide an example: case class DisplayName(name:String) implicit val displayNameWrite: Writes[DisplayName] = Writes { (displayName: DisplayName) => JsString(displayName.name) } But sadly I can't figure out how to do this for 1) a single nullable and

Intellij 14 Scala plugin 1.4: Play project not launching

天大地大妈咪最大 提交于 2019-12-13 00:29:19
问题 Today I got an update on Scala from 1.3.x to 1.4 After that, Intellij stopped launching my play projects. First when I would try to run activator from the command line, it gave me the following error Error: Unable to access jarfile <path to project>\activator-launch-1.2.8.jar So I replaced all the activator files from within the project. Then it started to run from the teriminal/console but when I hit Run/Debug on the my Play configuration in Intellij it simply makes the project and then

Play 2.3 subproject dependsOn

偶尔善良 提交于 2019-12-12 23:22:18
问题 This is how I configure the subprojects at Play 2.3. However, it gives me sbt.ResolveException: unresolved dependency. What is wrong with my settings? This works in 2.2. val model = Project(appName + "-model", file("models")).enablePlugins(play.PlayScala).settings( version := appVersion, libraryDependencies ++= modelDependencies ) val main = Project(appName, file(".")).enablePlugins(play.PlayScala).enablePlugins(SbtWeb).settings( version := appVersion, libraryDependencies ++= appDependencies

PlayFramework 2.6.x - Execute Application Startup Code

≡放荡痞女 提交于 2019-12-12 18:19:27
问题 This question is with regard to play! java 2.6.x I am attempting to bootstrap some initialization code which needs to be executed during application startup As per documentation, I have a class called Module in root package public class Module extends AbstractModule { private final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("application"); @Override public void configure() { logger.info("Loading Modules"); bind(ConsumerBootstrap.class).asEagerSingleton(); } } However it is

Anorm String Interpolation not replacing variables

北战南征 提交于 2019-12-12 16:03:30
问题 We are using Scala Play, and I am trying to ensure that all SQL queries are using Anorm's String Interpolation. It works with some queries, but many are not actually replacing the variables before the query is executing. import anorm.SQL import anorm.SqlStringInterpolation object SecureFile { val table = "secure_file" val pk = "secure_file_idx" ... // This method works exactly as I would hope def insert(secureFile: SecureFile): Option[Long] = { DBExec { implicit connection => SQL""" INSERT

Play Framework: Handling dynamic created files (images) in PRODUCTION mode

邮差的信 提交于 2019-12-12 10:13:09
问题 I'm trying to allow users to upload photos to the server and then view them (all users can view all photos) in production (NOT development). While in development mode everything is simple - I can upload the files to the public folder and then read then from there, in production mode I don't have access to the public folder anymore (as this approach is for static accesses and not dynamic). So, I have 2 issues: Upload: currently I can't understand how to save the uploaded photos to a specific

Anorm with Java 8 Date/Time API

房东的猫 提交于 2019-12-12 06:14:02
问题 I try to save timestamp field to postgresql using anorm. In scala code date/time stored as instance of java.time.Instant (someTime variable) DB.withConnection() { implicit c => SQL("INSERT INTO t_table(some_time) values ({someTime})").on('someTime -> someTime) } But anorm can't work with it now (Play 2.3.7). What is the best way to make it work? 回答1: I believe most people are using JodaTime so might explain why its missing. If its not part of Anorm you can write your own converter. This is

SBT unresolved dependency: com.paypal.sdk#paypal-core;LATEST

不羁岁月 提交于 2019-12-12 05:11:45
问题 I have a play framework 2.3.10 project and it can't find a paypal dependency. I suspect that it's due to the LATEST version tag (maybe it's a maven special version tag not supported by SBT?). [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: com.paypal.sdk#paypal-core;LATEST: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: sbt.ResolveException: unresolved dependency: com

Play Framework 2.3.x: Wrap Request object using Scala Oauth in Play Framework

百般思念 提交于 2019-12-12 03:02:20
问题 I am trying to Create customize action for security. I am using Scala Oauth for handling security in my application and trying to create custom action and wrap the Scala Oauth security in my custom action. According to Play Framework Documentation, i am using two ways for wrapped request object, but unfortunately, i am not getting my custom Request object in custom Action handler. Following are the Ways: case class AuthRequest[A](user: User, request: Request[A]) extends WrappedRequest[A]

Play Framework 2.3 How to add unique constraint to sample application

筅森魡賤 提交于 2019-12-11 12:44:51
问题 Given the Play Framework 2.3 Computer Database sample application, I would like to practice adding a unique constraint on an attribute. Let's say I want the name attribute of the Computer class to be unique. I've tried to do this by adding a validate() function (and a getter) to Computer.java : public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<ValidationError>(); if(Computer.find.where().eq("name", getName()).findRowCount() != 0){ errors.add(new