playframework-2.0

Play! framework - handle a POST request

自古美人都是妖i 提交于 2019-12-22 04:36:27
问题 this is the route to handle the login POST request: POST /login/submit controllers.Users.loginSubmit(user : String, password : String) this is the login.scala.html: <form method="post" action="???"> <input type="text" name="username" /><br/> <input type="password" name="password" /><br/> <input type="submit" value="Login" /> </form> I got two questions: what should be the value of action? is it "login/submit"? how do you pass this form to be handled in the loginSubmit function? thanks 回答1: If

Using the Playframework Scala @select template - onchange event

你说的曾经没有我的故事 提交于 2019-12-22 00:28:02
问题 I am using the playframework 2.0 with scala and I am facing many problem with the @select template. So what I have is a @select field as part of a Form (the Form shouldn't be interesting here): @select( Form("<variable of select 1>"), options = options(<call of function which returns a list>), '_default -> "--- stupid select templates ---", '_error -> Form.globalError ) now i have another select. Important about this one is - I want to fill it from a function, which gets the actual value of

How to create custom “package” task to jar up only specific package in SBT?

时光怂恿深爱的人放手 提交于 2019-12-21 23:25:08
问题 I have a Play project running on Play 2.1.1 . I would like to define a separate and distinct task to jar up only a specific package in my Play project (e.g. just the models package). I do not wish to override the current package tasks as I want to preserve their behaviour. How would I go about creating a custom task based off of the current package task? I've looked at Custom Settings and Tasks in the SBT documentation but these examples are fairly trivial and don't give any examples that use

Play Framework JSON Reader and custom JSErrors

假装没事ソ 提交于 2019-12-21 22:36:04
问题 I'm trying to read a JSON that could have the following parameters coming from the client { "email" : "foobar@gmail.com", "password" : "XXXX", "facebookToken": "XXXXXXXXXXX" } The facebookToken could be Null or Not present, in which case the Email/Password should be filled, and vice versa. I'm having trouble constructing this Reader, here's what I have so far: val loginEmail = ( ( __ \ "email").read[String] and ( __ \ "password").read[String] )((email: String, password: String) => new User

Accessing SSL secured web page from play application

半城伤御伤魂 提交于 2019-12-21 22:08:56
问题 I am accessing SSL secured pages from play app. When the certificate of the page can't be trusted (because it has expired or is self signed or whatever other reason it might be) I would like to extract this information from my call and do some action accordingly. When I access such a page in the browser, it warns me that there is something wrong with the certificate. When I write something like this in play (the https page here has a bad certificate): package controllers import play.api.mvc.

Using Ebean/JPA in my Play application, how can I delete an object in a OneToOne relationship?

旧街凉风 提交于 2019-12-21 21:56:15
问题 I have the following classes: import play.db.ebean.Model; import javax.persistence.*; @Entity public class A extends Model { @Id private int id; /* Other irrelevant properties */ @OneToOne(cascade = CascadeType.ALL, optional = true) private B b; } import play.db.ebean.Model; import javax.persistence.*; @Entity public class B extends Model { @Id private int id; /* Other irrelevant properties */ @OneToOne(mappedBy = "b") private A a; @OneToOne(cascade = CascadeType.ALL, optional = false)

Generate/Export excel file from Java Play Framework 2.0 List<object>

两盒软妹~` 提交于 2019-12-21 20:50:22
问题 I need to generate/export a excel file from a table that is generated from a list of objects. I can see that there is a module for Play 1.x but not for Play 2.x and. I found a possible solution but it is written in scala (I think) here: http://aishwaryasinghal.wordpress.com/2012/05/17/generating-excel-in-play-2/ I've tried to implement this but I think my imports doesn't work. import java.io.FileOutputStream; import org.apache.poi.xssf.usermodel.*; import org.apache.poi.xssf.*; import org

Play! framework - Cannot connect to database

核能气质少年 提交于 2019-12-21 20:21:02
问题 this is the error I get when I'm trying to connect to my local postgresql db: Cannot connect to database [default] this is the database configuration. I'm convinced that there is not typo (fat finger error) : db.default.url="postgres://localhost:5432/myproject/" db.default.user="postgres" db.default.pass="mypassword" db.default.driver="org.postgresql.Driver" db.default.initSQL="SELECT 1" where is the problem? with pgAdmin I can connect easily p.s. I'm using ubuntu. I've noticed that in order

Heroku app failing with code 255

房东的猫 提交于 2019-12-21 19:49:15
问题 Newbie to Heroku here. I've gone through the motions described here: http://www.playframework.org/documentation/2.0.2/ScalaTodoList And I've managed to set up a simple Play app on Heroku. Next up, I've tried uploading my main application which I've been developing on my own station, by going through the same steps as earlier. Uploading and compilation worked, however the app keeps crashing with code 255. Here is are the logs: 2012-08-21T19:07:29+00:00 heroku[slugc]: Slug compilation started

Is there a more appropriate way to set the language_in option for the closure compiler ( Play 2.1 )?

泪湿孤枕 提交于 2019-12-21 19:45:52
问题 I had to configure the language_in option in the closure compiler to ECMASCRIPT5 to compile the libs Ember, Angular and others it's require ES5... There must be a better way, but I implemented this way: // Build.scala val root = new java.io.File(".") val defaultOptions = new CompilerOptions() defaultOptions.closurePass = true defaultOptions.setProcessCommonJSModules(true) defaultOptions.setCommonJSModulePathPrefix(root.getCanonicalPath + "/app/assets/javascripts/") defaultOptions