playframework

Need to add a a header when returning an asset using the Play Framework Assets Controller

本秂侑毒 提交于 2020-01-07 02:01:52
问题 I need to return pdf files with the header X-Robots-Tag: noindex https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag?hl=de#robots-meta-tag-verwenden Is there a way to do this using the standard play Assets Controller? Took a look inside the source code and the only thing that seems to be configurable is: val configuredCacheControl = config(_.getString("\"assets.cache." + name + "\"")) Thanks 回答1: I might go with Kris's idea. Something kinda like this should get

Applying conversion to play framework json element before applying to class

我与影子孤独终老i 提交于 2020-01-07 01:48:31
问题 I have a class as so case class Token( creationDate: Date, expires: Option[Date] ) { def toJson(): String = Json.stringify(Json.toJson(this)) } object Token { def fromJson(json: String): Token = Json.parse(json).as[Token] implicit val tokenReads: Reads[Token] = ( (JsPath \ "creation_date").read[Date] and (JsPath \ "expires").readNullable[Date] ) (Token.apply _) implicit val tokenWrites: Writes[Token] = ( (JsPath \ "creation_date").write[Date] and (JsPath \ "expires").writeNullable[Date] )

Play form verification

好久不见. 提交于 2020-01-06 15:52:11
问题 How to add validation in play form? Below is reset password form which expects user to enter password twice. @(tokenId: String, form: Form[ResetPassword])(implicit messages: play.api.i18n.Messages, request: RequestHeader) @main("Reset Password") { @helper.form(routes.Application.handleResetPassword(tokenId)) { @helper.inputText(form("password1")) @helper.inputText(form("password2")) <button type="submit">Submit</button> } } In above form, I would like to add validation that will check if

NoClassDefFoundError: play/api/cache/CachePlugin

给你一囗甜甜゛ 提交于 2020-01-06 15:06:21
问题 Play Framework version is 2.4.6. When loading webpage I have error NoClassDefFoundError: play/api/cache/CachePlugin. I changed scala version from 2.10.5 to 2.11.6. java.lang.NoClassDefFoundError: play/api/cache/CachePlugin java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:760) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) java.net.URLClassLoader.defineClass(URLClassLoader.java:455) java.net.URLClassLoader.access$100

Updating Play app from JDK 6 to 7 on GAE

懵懂的女人 提交于 2020-01-06 07:48:49
问题 I have been developing a web app using play framework for a while (using eclipse). I was using Play 1.2.3 and JDK6 then I had to change my development environment (new pc) where I use JDK7. My dependencies were: require: - play - play -> crudsiena 2.0.1 - play -> siena 2.0.5 - play -> secure - play -> gae 1.6 - provided -> opencsv 2.3 - provided -> ddlutils_siena 1.0 - provided -> gae_aws_sdk 1.1.7.1 #- provided -> play 1.2.4 #- provided -> httpclient 4.1.1 #- provided -> httpcore 4.1

Heroku (PlayFramework/Scala) app automatically redirect to https

房东的猫 提交于 2020-01-06 07:25:38
问题 I have an PlayFramework App developed using Scala running on Heroku; I only mention the development language and framework because any posts I've found regarding this issue relate to PHP! I have http and https running on a custom domain but I would like to force http requests to be redirect to https. I've found that I need to update the .htaccess file with the following: ##Force SSL #Normal way (in case you need to deploy to NON-heroku) RewriteCond %{HTTPS} !=on #Heroku way RewriteCond %{HTTP

scala Returns Future[Unit] instead of Future[ContentComponentModel]

我的梦境 提交于 2020-01-06 07:21:33
问题 I have the following code: def getContentComponents: Action[AnyContent] = Action.async { val test = contentComponentDTO.list().map { contentComponentsFuture => contentComponentsFuture.foreach(contentComponentFuture => contentComponentFuture.typeOf match { case 1 => println("blubb") case 5 => contentComponentDTO.getContentComponentText(contentComponentFuture.id.get).map( text => { contentComponentFuture.text = text.text println(text.text) println(contentComponentFuture.text) } ) } ) } Future

NullPointer Exception while calling webservice in play framework

╄→尐↘猪︶ㄣ 提交于 2020-01-06 07:05:16
问题 Anything wrong in this program ? I am getting nullPointerException while calling web service in play framework in version 2.4.3. package com.enkindle.box; import javax.inject.Inject; import play.libs.ws.WSClient; /** * @author thirumal * */ public class Sample { @Inject WSClient ws; public static void main(String[] args) { Sample sample = new Sample(); sample.callAPI(); } public void callAPI() { ws.url("www.thomas-bayer.com/sqlrest/CUSTOMER/").get(); } } 回答1: The issue is that your Sample

NullPointer Exception while calling webservice in play framework

霸气de小男生 提交于 2020-01-06 07:03:12
问题 Anything wrong in this program ? I am getting nullPointerException while calling web service in play framework in version 2.4.3. package com.enkindle.box; import javax.inject.Inject; import play.libs.ws.WSClient; /** * @author thirumal * */ public class Sample { @Inject WSClient ws; public static void main(String[] args) { Sample sample = new Sample(); sample.callAPI(); } public void callAPI() { ws.url("www.thomas-bayer.com/sqlrest/CUSTOMER/").get(); } } 回答1: The issue is that your Sample

Play app with dependencies on 3 other play apps

余生颓废 提交于 2020-01-06 04:30:49
问题 I am running a play app, this app has dependencies on 3 other play apps, i.e. the first play app has 3 dependencies in build.sbt. Now of course all these 4 apps have their own route.conf file. The thing is when I start the first app, APIs for one of the jars start working instead of the app that i started. What I mean is that all the API urls for the first app is invalid and doesn't open while APIs of one of the jars that I added as a dependency starts working. Is there a way to stop this