Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • benjaminberry
    replied
    GwtRpcDataSource

    I couldn't include all the source for the datasource in one post so I made attachments instead.
    Attached Files

    Leave a comment:


  • benjaminberry
    started a topic GWT-RPC Datasource template

    GWT-RPC Datasource template

    I found myself writing a lot of boilerplate code for my DataSources that used GWT-RPC calls. Most of this code involves maintaining the internal data state of the DataSource and dependent widgets in the face of a possible failure occurring asynchronously after transformResponse is called.

    I've wrapped this code up into a reusable class, GwtRpcDataSource, with a helper class GwtRpcDataSourceEndpoint.

    You can set up to four endpoints on the datasource (fetch,add,update,remove).
    In each endpoint you must implement call endpoint. This is where you call your GWT-RPC service.
    You must pass the service the callback provided by the callEndpoint interface.
    If you are implementing an add/update/remove endpoint the first parameter in the variable arguments list will be the ListGridRecord being affected. If you are using bulkMode the first parameter will instead be a ListGridRecord array.
    If you are implementing the fetch command, it is assumed that your GWT-RPC call will return a Collection<T> where T is the type parameter you gave your GwtRpcdDataSource. If this is not true you must implement the transformResult object which will let you transmute the result Object into a Collection<T>.
    You must implement populateRecord on your GwtRpcDataSource, this is where you set the attributes of a record object with the data from your parametrized type T.
    The remaining parameters are whatever data you choose to cache on your GwtRpcDataSource via the setParameters call. This allows you to cache arbitrary data you may need to send to all your invocations.

    I've also included a sample implementation to make this more clear.
    Last edited by Isomorphic; 23 Mar 2009, 13:05.
Working...
X