[2.0 java] Anyone interested on a CRUD-Module

209 views
Skip to first unread message

opensource21

unread,
Jun 27, 2012, 7:45:05 AM6/27/12
to play-fr...@googlegroups.com
Hi,

after reading some negative impressions about writing a generic controller in play2.0 I started to implement a CRUD-module. You can find the code here: http://bazaar.launchpad.net/~opensource21/+junk/crud4play2/files/head:/samples-and-tests/crudsample/ It's far away from be ready to use, but I think the missing part is "straight forward" (Please inform me if you see problems). However the views must be written and the analysis of the model must be done.

Here are the concepts:
The customizing will completely done in the Controller. The view get a CrudForm which has a method to get all CrudFields which should be shown. A CrudField has a type (HIDDEN,INPUT_FIELD,DATE,TIME,DATE_TIME,COMBOBOX,CHECKBOX,RADIO_BUTTONS,MULTI_SELECT,READONLY,LINK,CUSTOM) and can provide custom html. So the view only must iterate over the field and render them depending on the type.

At the end the user must do only the following:
in routes
# CRUD
GET     /admin                 controllers.Admin.listCrudController()
GET     /admin/:table                     controllers.Admin.index(table: String)
GET     /admin/:table/list                controllers.Admin.list(table: String, p:Int ?= 0, s ?= "name", o ?= "asc", f ?= "")
GET     /admin/:table/show/$id<[0-9]+>    controllers.Admin.show(table: String, id: Long)
GET     /admin/:table/edit/$id<[0-9]+>    controllers.Admin.edit(table: String, id: Long)
POST    /admin/:table/edit/$id<[0-9]+>    controllers.Admin.update(table: String, id: Long)
GET     /admin/:table/create              controllers.Admin.create(table: String)
POST    /admin/:table/create              controllers.Admin.save(table: String)
POST    /admin/:table/delete/$id<[0-9]+>  controllers.Admin.delete(table: String, id: Long)

Write a Controller

public class Computers extends CRUD <Computer> {
    public Computers() {
        super(Computer.class);
    }
}

If there are special need this can be done in the controller. 

At the moment I didn't separate sample-code from plugin, because it's nasty to publish to repository and restart play completely (this can be done if the plugin becomes more stable).
I want to publish early to get feedback from the community and hopefully someone help with the views. Furthermore it would be good to know if this is from general interest.

Niels

opensource21

unread,
Oct 30, 2012, 10:32:09 AM10/30/12
to play-fr...@googlegroups.com
As I wrote "It's far away from be ready to use, but I think the missing part is "straight forward" (Please inform me if you see problems). However the views must be written and the analysis of the model must be done.". So there is still a lot of work to do, to make it work. Till know there was no interests on it.
Niels

Am Dienstag, 30. Oktober 2012 12:25:58 UTC+1 schrieb Rob:
Il giorno mercoledì 27 giugno 2012 13:45:05 UTC+2, opensource21 ha scritto:
Hi,

after reading some negative impressions about writing a generic controller in play2.0 I started to implement a CRUD-module. You can find the code here: http://bazaar.launchpad.net/~opensource21/+junk/crud4play2/files/head:/samples-and-tests/crudsample/ It's far away from be ready to use, but I think the missing part is "straight forward" (Please inform me if you see problems). However the views must be written and the analysis of the model must be done.

Hi Niels, have you written any tutorial or a step-by-step guide to make an example of your CRUD module?

Thanks.
Reply all
Reply to author
Forward
0 new messages