开发者

How do I setup for and/or handle onload event with GWT

This has to be a pretty basic question but I cannot for the life of me开发者_C百科 find anything via Google or this site about how to do this and it's really frustrating because I've gone through the GWT tutorial.

I'm trying to convert a javascript project I have to GWT. Right now I am trying to convert "" to something GWT equivalent. I've looked at RootPanel and I can't see anything.

Obviously I'm missing something fundamental in GWT ?!


Most widgets and panels in GWT implements the HasAttachHandlers interface. Adding an AttachEvent.Handler to these widgets/panels is equivalent to defining a function to run onload.

An example:

FlowPanel mainPanel = new FlowPanel();
mainPanel.addAttachHandler(new AttachEvent.Handler() {

  @Override
  public void onAttachOrDetach(AttachEvent event) {
    // do something
  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜