playframework-2.2

playframework JPA.em().merge(this)

情到浓时终转凉″ 提交于 2019-12-11 06:00:01
问题 I am trying to Insert my form to h2 database. I am using hibernate and jpa. Here is the code package models; import java.util.*; import javax.persistence.*; import play.data.format.*; import play.data.validation.*; import play.db.jpa.*; @Entity public class MedicalIncident { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) public int id; @Constraints.Required public String month; @Constraints.Required public String place; @Constraints.Required public String unit; @Constraints.Required

Play, Eclipse, Java generate project template

假如想象 提交于 2019-12-11 02:39:11
问题 I have a small problem with compiling default Play project to Eclipse template. Im doing as it is written, in tutorial: http://www.playframework.com/documentation/2.2.x/IDE This is my console output, it is step by step. Creating a project Running Play console Running "eclipse" command. C:\JAVA\Play>play new WareHouse _ _ __ | | __ _ _ _ | '_ \| |/ _' | || | | __/|_|\____|\__ / |_| |__/ play 2.2.2-RC3 built with Scala 2.10.3 (running Java 1.7.0_45), http://www.playf ramework.com The new

Play 2.2.2 with Java 11

試著忘記壹切 提交于 2019-12-10 19:04:44
问题 I have a Play 2.2.2 project I normally run with the activator 1.3.12 . Now I updated to Java 11 and activator complains like: The java installation you have is not up to date activator requires at least version 1.6+, you have version 11 Please go to http://www.java.com/getjava/ and download a valid Java Runtime and install before running activator. If I try to run the application with sbt 1.2.4 directly I get an unresolved dependency path error Note: Unresolved dependencies path: [warn] com

Set Accept-Language on PhantomJSDriver in a Play Framework Specification

最后都变了- 提交于 2019-12-10 15:54:29
问题 How can the PhantomJSDriver be configured with a specific Accept-Language language header in a Play Framework 2.2 specification? Given this code: import org.specs2.mutable._ import org.specs2.runner._ import org.junit.runner._ import play.api.i18n._ import play.api.test._ import play.api.test.Helpers._ import org.openqa.selenium.phantomjs.PhantomJSDriver @RunWith(classOf[JUnitRunner]) class IntegrationSpec extends Specification { "Application" should { "work from within a browser" in new

Play 2.2.1 SimpleResult 4xx Response Body Possible via CORS XHR?

荒凉一梦 提交于 2019-12-10 09:52:51
问题 I am attempting to send a JSON response body when my API serves up a 4xx http response code. Everything works fine when the code is 200, but changed to 4xx, no body is received. Postman for Chrome shows the body response, but XHR (Chrome, FF) does not. Is it even possible to get the response body inside an XHR with nginx CORS properly set up (I set it to simply echo ...Allow-Origin: $http_origin)? I have nginx as a proxy_pass to the actual API server on 127.0.0.1:9001. When I send in known

Date formatting with locale in Play Framework 2.2

亡梦爱人 提交于 2019-12-10 06:48:53
问题 From what I can see in the auto-generated application.conf file, dates/times in Play Framework 2.2 are formatted according to the definition of date.format in that file. I have, for instance, defined date.format=yyyy-MM-dd date.format.dk=d. MMMM yyyy These values, however, seem to be ignored by the framework when printing dates in Scala templates. This thread gives a solution where one enters the pattern directly into the template as myDate.format("yyyy-MM-dd") . (If using Jodatime I guess

Composing with Play's EssentialAction

流过昼夜 提交于 2019-12-09 22:58:52
问题 I'm using Play 2.2.1 and I'm trying to write my own Action to deal with CORS requests. I found this but unfortunately it doesn't compile. Just for reference here's the (slightly modified) code: import play.api.mvc._ import scala.concurrent.ExecutionContext case class CorsAction(action: EssentialAction) extends EssentialAction { def apply(request: RequestHeader) = { implicit val executionContext: ExecutionContext = play.api.libs.concurrent.Execution.defaultContext val origin = request.headers

Upgrading project to version 2.2.0 of the Play Framework

谁说我不能喝 提交于 2019-12-09 02:17:32
问题 When upgrading a play project to 2.2.0 the following error comes up: sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.2.0: not found 回答1: Edit the following line in project/plugin.sbt: addSbtPlugin("play" % "sbt-plugin" % "2.2.0") to addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0") Make sure you have the correct version of sbt in build.properties : sbt.version=0.13.0 回答2: There are even more things, that you need to do to upgrade your application: Play 2.2 migration

Test HTTP response with PlayFramework/JUnit

旧巷老猫 提交于 2019-12-09 02:15:34
I've been looking for hours to find a way to test if a route is correct with play. I mean, for exemple Is the GET request to localhost:9000/test actually return 200 OK ? I was not able to find any working example. I use Play's WS (Web Services) library to achieve this. For Example: package endpoints; import com.fasterxml.jackson.databind.JsonNode; import models.Meh; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import play.libs.Json; import play.libs.ws.WS; import play.libs.ws.WSResponse; import play.test.TestServer; import static org.fest.assertions

Scala Play Action.async cant resolve Ok as mvc.AnyContent

北战南征 提交于 2019-12-08 17:31:40
The following controller action cause the error: (block: => scala.concurrent.Future[play.api.mvc.SimpleResult])play.api.mvc.Action[play.api.mvc.AnyContent] cannot be applied to (scala.concurrent.Future[Object])". Every Future inside the action should be Ok() so I don't understand why scala can't resolve the futures correctly. def form = Action.async { val checkSetup: Future[Response] = EsClient.execute(new IndexExistsQuery("fbl_indices")) checkSetup map { case result if result.status == 200 => Ok("form") case result => { val createIndexResult: Future[Response] = EsClient.execute(new