Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

events

gwt

This has to be a pretty basic question but I cannot for the life of me 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 ?!

like image 347
Justin Avatar asked Apr 07 '11 02:04

Justin


1 Answers

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
  }
});
like image 152
smallbec Avatar answered Oct 18 '22 22:10

smallbec