Class LazyDomElement<T extends Element>

java.lang.Object
com.google.gwt.uibinder.client.LazyDomElement<T>
Type Parameters:
T - the Element type associated

public class LazyDomElement<T extends Element> extends Object
Wraps a call to a DOM element. LazyDomElement can boost performance of html elements and delay calls to getElementById() to when the element is actually used. But note that it will throw a RuntimeException in case the element is accessed but not yet attached in the DOM tree.

Usage example:

Template:

   <gwt:HTMLPanel>
      <div ui:field="myDiv" />
   </gwt:HTMLPanel>
 

Class:

   @UiField LazyDomElement<DivElement> myDiv;

   public setText(String text) {
     myDiv.get().setInnerHtml(text);
   }
 
  • Constructor Details

    • LazyDomElement

      public LazyDomElement(String domId)
      Creates an instance to fetch the element with the given id.
  • Method Details

    • get

      public T get()
      Returns the dom element.
      Returns:
      the dom element
      Throws:
      RuntimeException - if the element cannot be found