playframework-2.0

Play Framework - How to inherit from superclass?

a 夏天 提交于 2019-12-21 19:39:31
问题 I have a User class, which extends Model, and two classes that I want to extend the User class. User.java: @Entity @Table(name = "users") public class User extends Model implements RoleHolder { private static final long serialVersionUID = 1L; @Id public Long id; ... Driver.java: public class Driver extends User { ... Customer.java: public class Customer extends User { ... Edit All three entities need to be directly accessed. To say it another way, I have Users, Customers, and Drivers;

Using json with Play 2

泪湿孤枕 提交于 2019-12-21 19:28:23
问题 I'm trying to create a simple application that allows me to create, read, update and delete various users. I have a basic UI-based view, controller and model that work, but wanted to be more advanced than this and provide a RESTful json interface. However, despite reading everything I can find in the Play 2 documentation, the Play 2 Google groups and the stackoverflow website, I still can't get this to work. I've updated my controller based on previous feedback and I now believe it is based

When using a generic controller, how to return a view inherent to a specific controller?

∥☆過路亽.° 提交于 2019-12-21 13:08:34
问题 As a result of this answer: https://stackoverflow.com/a/10708026/694597, I am wondering how to return a view inherent to a specific controller when using a generic controller. 回答1: When you render a view in a controller action, you just invoke a plain function which has been generated by the template engine: public Application extends Controller { public static Result index() { return ok(views.html.index.render(42)); } } Here, render is a method of the object index which has type Template1

When using a generic controller, how to return a view inherent to a specific controller?

假如想象 提交于 2019-12-21 13:07:56
问题 As a result of this answer: https://stackoverflow.com/a/10708026/694597, I am wondering how to return a view inherent to a specific controller when using a generic controller. 回答1: When you render a view in a controller action, you just invoke a plain function which has been generated by the template engine: public Application extends Controller { public static Result index() { return ok(views.html.index.render(42)); } } Here, render is a method of the object index which has type Template1

Is it possible to use @PrePersist and @PreUpdate with eBean and Play! 2.0?

不想你离开。 提交于 2019-12-21 12:28:59
问题 I want to know if is it possible to use @PrePersist and @PreUpdate with Ebean and Play! 2.0. If so how is this feature activated. I've seen that there was a pull request adding this feature a month ago, but I can't make this work on Play 2.0. Thanks 回答1: If your goal is just setting createdAt or updatedAt fields, and you're using EBean, try @CreatedTimestamp and @UpdatedTimestamp . See here. I'd prefer to use Biesior's approach, but it seemed to fail on Cascades -- the methods were never

Scala Play framework: Binding form parameters to hidden fields

烂漫一生 提交于 2019-12-21 12:02:24
问题 I am working with Play 2.0.4 and have the following form in my scala template. @fieldGroup(field: Field, className: String = "field") = { <div class="twipsies well @className"> <a class="removeField btn danger pull-right">Remove Field</a> @inputText( // <=== I need a hidden input field here field("id") ) @inputText( field("name"), '_label -> "Name", '_help -> "Use lower case, starts with an alphabet can contain numbers and underscores." ) } I need a few hidden fields in my forms, how do I

Scala Play framework: Binding form parameters to hidden fields

时间秒杀一切 提交于 2019-12-21 12:02:23
问题 I am working with Play 2.0.4 and have the following form in my scala template. @fieldGroup(field: Field, className: String = "field") = { <div class="twipsies well @className"> <a class="removeField btn danger pull-right">Remove Field</a> @inputText( // <=== I need a hidden input field here field("id") ) @inputText( field("name"), '_label -> "Name", '_help -> "Use lower case, starts with an alphabet can contain numbers and underscores." ) } I need a few hidden fields in my forms, how do I

How to change HTTP port that Play2 is listening on

懵懂的女人 提交于 2019-12-21 08:14:53
问题 The documentation says: $ play start Note: the HTTP port can be set by passing -Dhttp.port system variable but I'm still hitting 9000 port taken error $ /opt/play-2.0/play start -Dhttp.port=9001 [info] Loading project definition from /my/path [info] Set current project to marmurka (in build file:/my/path/) (Starting server. Type Ctrl+D to exit logs, the server will remain in background) Play server process ID is 27505 [info] play - Application started (Prod) Oops, cannot start the server. org

How to change HTTP port that Play2 is listening on

被刻印的时光 ゝ 提交于 2019-12-21 08:14:30
问题 The documentation says: $ play start Note: the HTTP port can be set by passing -Dhttp.port system variable but I'm still hitting 9000 port taken error $ /opt/play-2.0/play start -Dhttp.port=9001 [info] Loading project definition from /my/path [info] Set current project to marmurka (in build file:/my/path/) (Starting server. Type Ctrl+D to exit logs, the server will remain in background) Play server process ID is 27505 [info] play - Application started (Prod) Oops, cannot start the server. org

Rolling an evolution back

久未见 提交于 2019-12-21 07:07:42
问题 This question might seem stupid, but I cannot find any instruction on how to roll back an evolution in Play 2.0. Google only finds pages which say that the "Downs" section of an evolution file is used for that and that's all. Any pointers or instructions will be appreciated. 回答1: The Downs part is mainly used to revert an Evolution when the script has changed. That is, you have a project with 2.sql applied to the database and then, due to a merge, 2.sql is modified in the source. Play will