playframework

How to change Play 2 Framework DB configuration at runtime?

走远了吗. 提交于 2019-12-30 09:35:12
问题 We are using Play 2.1.1 and its built-in JPA integration (JPA.em() etc). How can we dynamically change the db.pass property? Play.application().configuration() seems to be immutable as of Play 2.1. (or we're at least not aware of the mutators) If we are able to change db.pass, how can we reload the DB configuration so that JPA.em() returns an EntityManager using the new password? What we are trying to avoid is having to recreate the EntityManager using EntityManagerFactory. We want to

Library to Integrate Facebook login with Play Framework?

 ̄綄美尐妖づ 提交于 2019-12-30 08:33:29
问题 I'm learning using Play Framework and doing a demo app for it. For this app I want also to integrate with the Facebook API, allowing users to log using Facebook Ids. Knowing that Play is a stateless framework and the way it works, there is some library or module recommended? I've not been able to find any but I ask just in case. 回答1: RestFB is my first choice. The Facebook Java API should also do. 回答2: The latest Play! Framework v1.2.2 contains a sample with Facebook OAuth2 protocol. Here is

conversion of array list to json object string

旧巷老猫 提交于 2019-12-30 04:11:06
问题 I have a model class method which returns a list of objects which contains all the registered user details. I want to fetch the list resturned by all() method and convert the data into JSON object and pass it to the view like a string. How can I do this conversion of this array list to JSON object? I was unable to do this by below: ObjectMapper mapper = new ObjectMapper(); JSONObject json = new JSONObject(); JsonNodeFactory jsonnode = JsonNodeFactory.instance; ObjectNode result = new

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

Where is sbt inside Typesafe Activator?

穿精又带淫゛_ 提交于 2019-12-30 01:41:26
问题 I am trying out the Play Framework 2.3.2 using the offline installation with Typesafe Activator 1.2.3. Every piece of documentation tells me that it's using sbt under the covers to build and run projects. Where is this sbt located/installed? Is it somewhere in the unzipped folder that contained the Activator installation? How do I start sbt from command line? It's not on the PATH as running locate sbt finds nothing. 回答1: The activator-launcher-<version>.jar is actually the sbt launcher with

Why use @Singleton over Scala's object in Play Framework?

梦想的初衷 提交于 2019-12-30 01:37:17
问题 I have been using Play! Framework for Scala for nearly a year now. I am currently using version 2.5.x. I am aware of the evolution of controllers in Play and how developers have been forced away from static object routes. I am also aware of the Guice usage in play. If you download activator and run: activator new my-test-app play-scala Activator will produce a template project for you. My question is specifically around this file of that template. my-test-app/app/services/Counter.scala

Multiple Databases with Play Framework 2.1.x

女生的网名这么多〃 提交于 2019-12-29 21:10:57
问题 I have 2 databases that I need to connect to. I can easily connect to them in the application.conf file like so: db.default.driver=org.postgresql.Driver db.default.url="jdbc:postgresql://localhost/db1" db.default.user=postgres db.default.password="password" db.secondary.driver=org.postgresql.Driver db.secondary.url="jdbc:postgresql://localhost/db2" db.secondary.user=postgres db.secondary.password="password" ebean.default="models.db1.*" ebean.secondary="models.db2.*" I have my model classes in

22 Column limit for procedures

可紊 提交于 2019-12-29 06:57:10
问题 How can we overcome the 22 limit when calling procedures with Slick? We currently have: val q3 = sql"""call getStatements(${accountNumber})""".as[Transaction] The problem is that we have to return more than 22 columns and Transaction case class cannot have more than 22 columns since when we do JSONFormat we get an error: [error] E:\IdeaProjects\admin\Transaction.scala:59: No unapply or unapplySeq function found [error] implicit val jsonFormat = Json.format[Transaction] Any suggestions? 回答1:

Is there a default method to read a file in play which works even in the production environment?

删除回忆录丶 提交于 2019-12-29 04:57:05
问题 I am using play framework with java to develop a web application. I have wanted to read a file at the run time and the file has been included in a folder in the project. But at the production environment the folder is not available. Is there a way to make the folder available at the run time? And specially, is there a default method in play to handle such a scenario? I went through the question "How to read a file in Play Framework 2.2.1?1" But there is no mention about the problem in the