Class LazyPanel

java.lang.Object
All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, AcceptsOneWidget, HasOneWidget, HasVisibility, HasWidgets, HasWidgets.ForIsWidget, IsWidget, Iterable<Widget>

public abstract class LazyPanel extends SimplePanel
Convenience class to help lazy loading. The bulk of a LazyPanel is not instantiated until setVisible(boolean)(true) or ensureWidget() is called.

Example

public class LazyPanelExample implements EntryPoint {

  private static class HelloLazyPanel extends LazyPanel {
    @Override
    protected Widget createWidget() {
      return new Label("Well hello there!");
    }
  }

  public void onModuleLoad() {
    final Widget lazy = new HelloLazyPanel();
    
    // Not strictly necessary, but keeps the empty outer div
    // from effecting layout before it is of any use
    lazy.setVisible(false);

    PushButton b = new PushButton("Click me");    
    b.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        lazy.setVisible(true);
      }
    });
    
    RootPanel root = RootPanel.get();
    root.add(b);
    root.add(lazy);
  }
}