Class LazyDomElement<T extends Element>

  • Type Parameters:
    T - the Element type associated

    public class LazyDomElement<T extends Element>
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      LazyDomElement​(java.lang.String domId)
      Creates an instance to fetch the element with the given id.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()
      Returns the dom element.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LazyDomElement

        public LazyDomElement​(java.lang.String domId)
        Creates an instance to fetch the element with the given id.
    • Method Detail

      • get

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