Finding out when a GWT module has loaded

前端 未结 1 1133
攒了一身酷
攒了一身酷 2021-01-01 02:47

I am exporting a GWT method to native javascript in the following manner:

public class FaceBookGalleryEntryPoint implements EntryPoint {

    @Override
    p         


        
相关标签:
1条回答
  • 2021-01-01 03:43

    I would try to define a callback function in the hostpage and call it from GWT at the end of the onModuleLoad() method.

    Hostpage function:

    <script type="text/javascript">
      function onGwtReady() {
        loadGallery('blargh');              
      };
    </script>
    

    GWT:

    public void onModuleLoad() {
      FacebookGallery facebookGallery = new FacebookGallery();
      RootPanel.get().add(facebookGallery);
    
      initLoadGallery(facebookGallery);
    
      // Using a deferred command ensures that notifyHostpage() is called after
      // GWT initialisation is finished.
      Scheduler.get().scheduleDeferred(new Command() {
        public void execute() {
          notifyHostpage();
        }
      }
    }
    
    private native void notifyHostpage() /*-{
      $wnd.onGwtReady();
    }-*/;
    
    0 讨论(0)
提交回复
热议问题