Class HTMLPanel

    • Constructor Detail

      • HTMLPanel

        public HTMLPanel​(java.lang.String html)
        Creates an HTML panel with the specified HTML contents inside a DIV element. Any element within this HTML that has a specified id can contain a child widget.
        Parameters:
        html - the panel's HTML
      • HTMLPanel

        public HTMLPanel​(SafeHtml safeHtml)
        Initializes the panel's HTML from a given SafeHtml object. Similar to HTMLPanel(String)
        Parameters:
        safeHtml - the html to set.
      • HTMLPanel

        public HTMLPanel​(java.lang.String tag,
                         java.lang.String html)
        Creates an HTML panel whose root element has the given tag, and with the specified HTML contents. Any element within this HTML that has a specified id can contain a child widget.
        Parameters:
        tag - the tag of the root element
        html - the panel's HTML
    • Method Detail

      • createUniqueId

        public static java.lang.String createUniqueId()
        A helper method for creating unique IDs for elements within dynamically- generated HTML. This is important because no two elements in a document should have the same id.
        Returns:
        a new unique identifier
      • wrap

        public static HTMLPanel wrap​(Element element)
        Creates an HTML panel that wraps an existing element. This element must already be attached to the document. If the element is removed from the document, you must call RootPanel.detachNow(Widget).
        Parameters:
        element - the element to be wrapped
      • add

        public void add​(Widget widget,
                        java.lang.String id)
        Adds a child widget to the panel, contained within the HTML element specified by a given id.
        Parameters:
        widget - the widget to be added
        id - the id of the element within which it will be contained
      • add

        public void add​(Widget widget,
                        Element elem)
        Adds a child widget to the panel, contained within an HTML element. It is up to the caller to ensure that the given element is a child of this panel's root element.
        Overrides:
        add in class ComplexPanel
        Parameters:
        widget - the widget to be added
        elem - the element within which it will be contained
      • addAndReplaceElement

        public final void addAndReplaceElement​(Widget widget,
                                               Element toReplace)
        Adds a child widget to the panel, replacing the HTML element.
        Parameters:
        widget - the widget to be added
        toReplace - the element to be replaced by the widget
      • addAndReplaceElement

        @Deprecated
        public void addAndReplaceElement​(Widget widget,
                                         Element toReplace)
        Adds a child widget to the panel, replacing the HTML element.
        Parameters:
        widget - the widget to be added
        toReplace - the element to be replaced by the widget
      • addAndReplaceElement

        public void addAndReplaceElement​(Widget widget,
                                         java.lang.String id)
        Adds a child widget to the panel, replacing the HTML element specified by a given id.
        Parameters:
        widget - the widget to be added
        id - the id of the element to be replaced by the widget
      • getElementById

        public Element getElementById​(java.lang.String id)
        Finds an element within this panel by its id. This method uses Document.getElementById(String), so the id must still be unique within the document.
        Parameters:
        id - the id of the element to be found
        Returns:
        the element with the given id, or null if none is found