playframework-2.3

Play 2.3 implicit json conversion causes null pointer exception

前提是你 提交于 2019-12-30 03:58:05
问题 I'm trying to parse json into my case class DealFormMap case class DealFormMap(limit: Option[Int], filter: Option[DealFormFilterMap]) case class DealFormFilterMap(date: Option[String], code: Option[String]) implicit val dealFormMapReads: Reads[DealFormMap] = ( (JsPath \ "limit").readNullable[Int] and (JsPath \ "filter").readNullable[DealFormFilterMap] )(DealFormMap) implicit val dealFormFilterMapReads: Reads[DealFormFilterMap] = ( (JsPath \ "date").readNullable[String] and (JsPath \ "code")

Caching an action in a multi-language website using Play Framework's Cached API

安稳与你 提交于 2019-12-30 03:45:10
问题 In order to cache actions per label and language for a given number of seconds, I wrote the following helper method (where label, is the name I give to my action): def cacheResponseFor(label: String, duration: Int)(action: EssentialAction) = { Cached({r: RequestHeader => (label + getLanguage(r))}, duration){ action } } def getLanguage(request: RequestHeader): String = { request.cookies .get(helpers.SessionHelpers.LANGUAGE_SESSION) .map(_.value) .getOrElse(helpers.LanguageHelpers.FRENCH) } But

Why does sbt fail with NoClassDefFoundError: play/Play$ in Play 2.2.x projects after sbt compile in Play 2.3 project?

懵懂的女人 提交于 2019-12-29 06:43:06
问题 Once I run 'sbt compile' on a 2.3 play project, I can't use 'sbt compile' to compile any Play 2.2.x projects anymore. This is the error when I run sbt command. [info] Loading project definition from /Users/macbookpro/playproject/project [error] java.lang.NoClassDefFoundError: play/Play$ [error] Use 'last' for the full log. Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 回答1: I just had this same issue. In my case I was using Play 2.4, but it's probably the same cause. I had run

Play-Framework 2.3.x: Unable to send emails using plugin “play-mailer”

非 Y 不嫁゛ 提交于 2019-12-25 06:13:07
问题 I am using play-framework 2.3.x and scala 2.11.4 . When integrate play-mailer for sending and emails from my application, there is nothing happen. In the logs there are no exception produces and no return values are available. Following is email properties: smtp.host = "smtp.gmail.com" smtp.port = 25 smtp.user = "n****@gmail.com" smtp.password = "*******" smtp.debug = true smtp.mock = true My Scala Code: Future{ var subject = "Invitation email"; var from = "h****@gmail.com"; var to = userList

How can I tell the contents of a webjar?

▼魔方 西西 提交于 2019-12-25 04:43:52
问题 Let's say I want to use the webjar react-0.12.2 in my Play Framework 2.3 project, and I've depended on it like so: libraryDependencies ++= Seq( "org.webjars" %% "webjars-play" % "2.3.0-2", "org.webjars" % "react" % "0.12.2" ) How do I tell which assets are available in the react webjar? If I try to access simply "react.js", like in the following example, I get an error due to there being multiple matches for react.js: <script type='text/javascript' src='@routes.WebJarAssets.at(WebJarAssets

Logs not showing up Scala Play 2.3.x

核能气质少年 提交于 2019-12-24 18:05:57
问题 I am trying to my logs to show up in my play console. Here is an example of a controller I am trying to log information from : import play.api.Logger object LandingPage extends Controller { import ComponentRegistry._ private val emailForm = Form(mapping("id" -> optional(of[Long]), "emailAddress" -> email)(Email.apply _)(Email.unapply _)) def index = Action { Logger.info("Index method inside of LandingPage") Ok("INDEX") } def submit = Action { implicit request => Logger.info("Inside of submit

where to place the public directory for play framework after using the dist command

寵の児 提交于 2019-12-24 17:50:02
问题 I am using the 'dist' command with play framework v2.5. However, when I unzip the file, it does not create the public directory. I have the following directories: bin, conf, lib, logs and share (contains doc). Where should I place the public directory whereby this would work exactly like it does with the play framework (not having run the dist command) i.e. I can place static assets in the public directory and have them served from there (I do not wish to use a CDN for this purpose as of now)

Can I ignore the “twitter bootstrap is deprecated” warnings in my code?

…衆ロ難τιáo~ 提交于 2019-12-24 16:58:17
问题 I am using the play framework 2.3.8 with twitter Bootstrap 3.3.4 and have several forms in my application, where you can enter input. Sample: @import models.Question @import models.Answer @import helper._ @import helper.twitterBootstrap._ @(questionForm: Form[Question], questionList: List[Question]) @main("Ask Question"){ @helper.form(action = routes.Application.sendQuestion()){ <fieldset> @helper.inputText(questionForm("questionID")) @helper.inputText(questionForm("questionText")) @helper

Play dist task: how to prevent conf files to be packed

ぐ巨炮叔叔 提交于 2019-12-24 16:13:06
问题 When running dist task, distribution package includes conf files (from <app>/conf ) in two places: <app.zip>/conf <app.zip>/lib/<app.jar> This means that application.conf (and all the other conf files whithin <app>/conf ) will be placed both in the root of the zip package, and in the root of the main jar library. When running the application, files inside jar are the ones used, so copies in the <unzipped-app>/conf are completely ignored. I'm wondering which is the best practice here: I think

Play Framework Ebean two ManyToMany relations return same data

流过昼夜 提交于 2019-12-24 13:42:36
问题 My code looks like this: @Entity public class Document extends Model { @Id private Long id; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "developers") private Set<Tester> developers = new HashSet<>(); @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "testers") private Set<Tester> testers = new HashSet<>(); } I am using the JoinTable annotation otherwise I end up with the same join table for the many-to-many relation. This works well and I get two tables generated