service.getConversationContexts(new Callback<Representation>() {
public void onSuccess(Representation data) {
List<ConvCtxSummaryModel> models = new ArrayList<ConvCtxSummaryModel>();
JsArray<JSOModel> a = JSOModel.fromJson(data.getData()).getArray("definition");
for (int i = 0; i < a.length(); i++) {
ConvCtxSummaryModel model =
new ConvCtxSummaryModel(a.get(i).getObject(ConvCtxSummaryModel.ROOT));
models.add(model);
}
eventBus.fireEvent(new ConversationsLoadedEvent(models));
}
});
Thanks,Read the "Updates for GWT 2.0 (In-progress DRAFT)" section of:
http://code.google.com/p/google-web-toolkit/wiki/OverlayTypes
Your proposed solutions all look good to me:
- (except this one!) detect when unit tests are running: you actually
want to detect whether you're in "pure Java" or "GWT client", use
GWT.isClient()
- modify presenters and services: I'm experimenting a similar method:
I actually use a GWT-RPC Async interface but instead of having the
client stub generated (i.e. let GIN fallback to GWT.create()) I make
my own implementation using RequestBuilder and JSON parsing. You're
not forced to use GWT-RPC Async-like (using AsyncCalback) interfaces,
you can make your own callback interface if AsyncCallback doesn't fit
your needs; but all in all, what I mean is that the JSON parsing
should be hidden, an "implementation detail" of your service
implementation.
- make JSOModel an interface: that's part of my experiment too;
except that I'm envisionning changing from a wrapper (similar to your
BaseModel, but mine isn't generic and entirely implemented using JSNI
methods) to a JSO overlay when I'll switch to GWT 2.0. Just that,
because I actually never used GWT-RPC, I don't know how it works (or
not) when arguments and return values are interfaces, so using
AsyncCallback and GWT-RPC-like interfaces might not be a good choice
after all (I even code the "sync", RemoteService interface, to please
the Google Plug-in for Eclipse; I haven't used it yet, but I thought
about using dummy service servlets for some "demo apps")
Have you considered using gin/mock classes to test your overlays and
high-level RPC calls? I've found that technique to be quite helpful.