> What is the reason for IsWidget only returning the widget and not
> having all of the public methods available to widget?
The IsWidget is only there so you can mock the view without any
dependency on Widget. In your unit tests you can then check whether
the IsWidget is null or is the object you're expecting, but you don't
really care what it does (this is left to the view interfaces, which
will likely extend IsWidget).
The typical ussage is:
interface MyView extends IsWidget {
   interface Delegate {
      onFoo();
   }
   void setDelegate(Delegate delegate);
}
class MyActivity implements Activity, MyView.Delegate {
   @Inject MyView view;
   public void start(AcceptsOneWidget panel, EventBus eventBus) {
      view.setDelegate(this);
      doAsyncStartup(new WhateverCallback() {
         public void onSuccess() {
             if (view == null) {
                // we've been cancelled!
                return;
             }
             ...
             panel.setWidget(view);
         }
      });
   }
   public void onCancel() {
      view.setDelegate(null);
      view = null; // serves as a flag to know if we're still active
   }
   public void onStop() {
      // same as in onCancel, possibly more
   }
   public String mayStop() { ... }
}
With doAsyncStartup generally being a GWT-RPC, RequestFactory or
RequestBuilder call, and WhateverCallback the appropriate callback
interface (AsyncCallback, Receiver or RequestCallback)
(if you annotate the View interface with @ImplementedBy, you don't
even need to explicitly configure anything in GIN)
-- 
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
 
No comments:
Post a Comment