playframework

What are the steps for migrating from Play! 1.1 to 2.0?

痞子三分冷 提交于 2020-01-06 04:10:26
问题 Is there any documentation on how to migrate from Play! 1.1 to Play! 2.0? I understand that I would need to rewrite the templates, but what additional steps would I need to perform to be up to date? The app is written in Java with some jQuery with AJAX. I'm not using any NHibernate in it. On a similar note, is the effort actually worth it? Or should I upgrade to 1.2 and not worry about 2.0? 回答1: play 2 is not play1.2.5+, which means you don't get all the features you get in play1.2.4 and some

Relational Data is Not Fetching in Ebean

ε祈祈猫儿з 提交于 2020-01-06 03:51:04
问题 Background I am using Play Framework(Java) to store data. Play Framework uses Ebean to convert classes into data that can be stored in a a database. Issue I am currently having trouble fetching relational data completely. I have a User and a UserEmail model. The User can own multiple UserEmail s. User Model Code User Email Model Code When I try and fetch a User , the User data is fetched correctly, however the UserEmail s are not. Fetching Code When I specifically add fetch("emails") to the

scala playframework json implicit case class conversion

蹲街弑〆低调 提交于 2020-01-05 12:09:06
问题 I am developing my first Play 2.1 application in Scala. The task I am trying to accomplish is to parse json into 3 different case classes. The problem is - I do not know where to declare all case classes. Each class in it's own file or all in one file. Here is what I've done (it doesn't work, case values are not visible in controller object): File LoginBase.scala package models abstract class LoginBase case class Login(email: String, password: String) extends LoginBase case class RestoreLogin

Play framework 2: Passing java objects between controllers

一笑奈何 提交于 2020-01-05 10:35:32
问题 I have a java User object which i want to pass from my Login controller to my Dashboard controller. ive read a bunch and im trying the following implementation public static Result authenticate(){ Form<LoginForm> loginform = Form.form(LoginForm.class).bindFromRequest(); if(loginform.hasErrors()){ return badRequest(login.render(loginform)); } else{ session().clear(); AppUser user = AppUser.getUserByEmail(loginform.get().email); Context.current().args.put("user", user); return redirect(routes

call simple database procedure using Slick 3.0

ε祈祈猫儿з 提交于 2020-01-05 10:35:04
问题 I have written a simple database procedure in mySQL as follows: DROP PROCEDURE IF EXISTS sp_doSomething; DELIMITER // CREATE PROCEDURE sp_doSomething (IN pVal1 varchar(100), IN pVal2 int(15) ) BEGIN DECLARE vCnt int(5) DEFAULT 0; DECLARE vID int(15) DEFAULT 0; DECLARE vTempID int(15) DEFAULT 0; -- get ID SELECT id INTO vID FROM T1 WHERE name = pVal1; -- get count SELECT count(*) INTO vCnt FROM T1 WHERE owner = vID; -- get the log INSERT INTO log select CONCAT('-v1-:', pVal1, ':-v2-:', pVal2);

Play framework 2: Passing java objects between controllers

巧了我就是萌 提交于 2020-01-05 10:34:46
问题 I have a java User object which i want to pass from my Login controller to my Dashboard controller. ive read a bunch and im trying the following implementation public static Result authenticate(){ Form<LoginForm> loginform = Form.form(LoginForm.class).bindFromRequest(); if(loginform.hasErrors()){ return badRequest(login.render(loginform)); } else{ session().clear(); AppUser user = AppUser.getUserByEmail(loginform.get().email); Context.current().args.put("user", user); return redirect(routes

Play framework JSON list binding

房东的猫 提交于 2020-01-05 10:13:14
问题 I am new into Play, and I want to try to bind a List of String from a JSON post. I do the following: import play.data.validation.Constraints; import java.util.ArrayList; import java.util.List; Form<Person> PERSON = new Form<>(Person.class); Form<Person> filledForm = PERSON.bind(request().body().asJson()); Person class { @Constraints.Required @Constraints.Email private String email; @Constraints.Required private List<String> adresses = new ArrayList<>(); } I get the following message: "matches

How to show field error inline in the form?

别来无恙 提交于 2020-01-05 09:48:07
问题 I defined a case class and a form object to handle form submission. case class NewUser( userName: String, password: String, email: String ) val form = Form( mapping( "userName" -> nonEmptyText.verifying("The username already exists", User.userNameExists(_) == false), "password" -> tuple( "main" -> nonEmptyText, "confirm" -> nonEmptyText ).verifying( "Password does not match confirmed password", password => password._1 == password._2 ).transform[String]( password => password._1, password => ("

How to show field error inline in the form?

房东的猫 提交于 2020-01-05 09:47:17
问题 I defined a case class and a form object to handle form submission. case class NewUser( userName: String, password: String, email: String ) val form = Form( mapping( "userName" -> nonEmptyText.verifying("The username already exists", User.userNameExists(_) == false), "password" -> tuple( "main" -> nonEmptyText, "confirm" -> nonEmptyText ).verifying( "Password does not match confirmed password", password => password._1 == password._2 ).transform[String]( password => password._1, password => ("

Play, REST, and Authentication

末鹿安然 提交于 2020-01-05 09:28:50
问题 I'm implementing a REST api with Play... and I know a REST api should be stateless. Well, my api is an hybrid, in the sense that when an user authenticates, I send back a token to be used to sign any subsequent request. This token expires after an amount of time the user no longer sends requests to the server – on the server side, I use a MongoDB collection to handle active tokens. Now my question is: how should I deal with this token? Should the request contain the token in the body? Or