Information on GWT-Plus
GWT-Plus is an addon module to GWT-Ext.
Here are the high level features of the Store / GWT-RPC integration :- Integrates the data returned by a GWT-RPC service call into a GWT-Ext Store
- Also supports loading a List of local beans into a GWT-Ext Store
- Transparent and seamless mapping of Store and Record API's with the underlying user JavaBean object
- Support for read and write of nested JavaBean properties (unlimited nesting)
- Store#getModifiedRecords() allows you to get a list of modified JavaBean objects which can then be sent to the server
- Fine grain control of which properties are exposed to the Record API as fields
- Integration of GWT-RPC exception with associated Store exceptions
- Propagation of sort / page / filter and user defined parameters to user's RPC call in a flexible way without enforcing a specific API on the RPC call
- Support for GWT 1.5 and Generics
- Demo of an EditableGrid which gets data using GWT-RPC and also demonstrates passing back the modified beans to the server. Additionally the table paging parameters (page size , page num) and sorting parameters from the Grid are made available to the RPC call and passed to the server.
- Same as above except that the data is laoded using a List of local data beans.
- An example of ComboBox - Form - Grid example where all three widgets are bound to the same underlying data which is retreived using a GWT-RPC call. The ComboBox data is pageable, and a selection dispalys to corresponding Record in the Form and Grid. Selecting a row in the Grid results in the selected Record being dispalyed in the Form. Editing the Record in the Form reflects in the Grid and conversely editing a cell in the Grid reflects in the Form.
- Same as above except that the data is loaded using a List of local data beans.
Buy GWT-Plus
You can find information on purchasing GWT-Plus here.
Below is some sample code illustrating the usage of GWT-Plus Store / RPC integration that should give you a good idea of how things work.
final MyServiceServiceAsync myservice = ...
BeanProxy proxy = new BeanProxy(new RemoteLoader() {
public void load(AsyncCallback callback, FetchCriteria fetchCriteria) {
//your application service API call,
//for example
myservice.getPersons(callback);
}});
//here Person class is your Bean class.
BeanAdapter beanAdapter = (BeanAdapter) GWT.create(Person.class);
//either get a generated RecordDef with all the bean properties
RecordDef recordDef = beanAdapter.getRecordDef();
//or simply create on yourself as usual explicilty listing the properties
RecordDef recordDef = new RecordDef(new FieldDef[]{
new StringFieldDef("name"),
new StringFieldDef("birthday"),
new StringFieldDef("state", " person.address.state") //can also bind nested properties
});
BeanReader reader = new BeanReader(beanAdapter, recordDef);
final Store store = new Store(proxy, reader);
store.addStoreListener (new StoreListenerAdapter() {
public void onLoad(Store store, Record[] records) {
super.onLoad(store, records);
Record record = records[0];
record.set( "name", "sanjiv");
//this is your server java bean
Person bean = (Person) record.getDataAsObject();
}
public void onLoadException(Throwable error) {
//here you get any RPC related exception (eg any exception your service API may throw)
}
});
store.load ();
Modifications made to the Records will be aware of underlying beans. So edits to rows in a grid will result in updates to the underlying bean. To find modified beans, call Store#getModifiedRecords(), iterate over each record and extract your Bean via record.getDataAsObject(). Then pass to server to save or whatever, and then call store#commit() as usual.
Questions?
Please send mail to gwt.plus@gmail.com.