-
Notifications
You must be signed in to change notification settings - Fork 2
scaffold options
resty-generators will add some more options to the scaffold/model generators.
- singleton
- timestamps
- modified-by
- optimistic
- readonly - (pending)
the first three will affect the signature of a model, i.e. the gwt editor of a model has a read only attributes for each model: id, created_at, updated_at, modified_by. these attributes of model comes in with one of the following option.
- id: singleton
- created_at, updated_at: timestamps
- modified_by: modified-by
the modified class will be User that is hard coded right now. this is class with couple of attributes - no AR or DM or any other persistent framework in place.
the optimistic option needs to have timestamps as well and is merely something for the controller. when finding an existing model the updated_at timestamps must match as well, otherwise the model is stale (if there is a model for the given id). stale model can not be saved or deleted and will response with a conflict http status. AR offers this via an explicit version column and this here is reusing the existing updated_at column.
rails generate scaffold location name:string country:belongs_to
will use Country as belongs_to class both on the rails side as well on GWT side. the editors for that location will have a dropdown list with countries to select a country, i.e. the whole round with creating, updating and deleting such model with belongs_to gets scaffolded and is ready to use.
src/main/java/com/example/client/ ├── activities │ └── AccountActivity.java ├── editors │ ├── AccountEditor.java │ └── AccountEditor.ui.xml ├── events │ ├── AccountEventHandler.java │ └── AccountEvent.java ├── models │ └── Account.java ├── places │ ├── AccountPlace.java │ └── AccountPlaceTokenizer.java ├── restservices │ └── AccountsRestService.java └── views ├── AccountViewImpl.java ├── AccountView.java └── AccountView.ui.xml
- activities: loads the data from server and fires respective events, pushes the response into the view, etc
- editors: is input form for the model
- model: data and maybe more logic
- places: the tokenizer maps the url pattern to a place
- restservices: the transport layer for the model to server
- views: adds save, create, new, delete, etc buttons and the actual editor, or the list of models.
- *.ui.xml files are the GWT template files
see also on the GWT website for activites + places or editors or GWT templates.
google-gin is used to wire all components together. most of the generated components all GIN bindings are done via annotations.
the code points which plugs in all the classes for a new resource (Account in the list below) are (where the application name is MyApp):
- src/main/java/com/example/client/managed/MyAppPlaceHistoryMapper.java which gets the history tokenizer registered for the new resource
-
src/main/java/com/example/client/managed/ActivityFactory.java which is a parametrizied gin-factory. this allows the
AccountActivity
to be managed by GIN -
src/main/java/com/example/client/managed/MyAppMenuPanel.java is just a list of buttons which triggers a
PlaceController.goTo(Place)
-
src/main/java/com/example/client/managed/MyAppModule.java gets a provider to make the
AccountsRestService
a singleton and adds theAccountActivity
to the ActivityFactory