public class

HTMLPanel

extends ComplexPanel
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.Panel
         ↳ com.google.gwt.user.client.ui.ComplexPanel
           ↳ com.google.gwt.user.client.ui.HTMLPanel

Class Overview

A panel that contains HTML, and which can attach child widgets to identified elements within that HTML.

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
HTMLPanel(String html)
Creates an HTML panel with the specified HTML contents inside a DIV element.
HTMLPanel(SafeHtml safeHtml)
Initializes the panel's HTML from a given SafeHtml object.
HTMLPanel(String tag, String html)
Creates an HTML panel whose root element has the given tag, and with the specified HTML contents.
Public Methods
void add(Widget widget, Element elem)
Adds a child widget to the panel, contained within an HTML element.
void add(Widget widget, String id)
Adds a child widget to the panel, contained within the HTML element specified by a given id.
void add(Widget widget)
Adds a child widget to the panel.
void addAndReplaceElement(Widget widget, Element toReplace)
This method is deprecated. use addAndReplaceElement(Widget, Element)
final void addAndReplaceElement(Widget widget, Element toReplace)
Adds a child widget to the panel, replacing the HTML element.
void addAndReplaceElement(Widget widget, String id)
Adds a child widget to the panel, replacing the HTML element specified by a given id.
static String createUniqueId()
A helper method for creating unique IDs for elements within dynamically- generated HTML.
Element getElementById(String id)
Finds an element within this panel by its id.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.ComplexPanel
From class com.google.gwt.user.client.ui.Panel
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.HasWidgets
From interface com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
From interface com.google.gwt.user.client.ui.IndexedPanel
From interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget
From interface com.google.gwt.user.client.ui.IsWidget
From interface java.lang.Iterable

Public Constructors

public HTMLPanel (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

public HTMLPanel (SafeHtml safeHtml)

Initializes the panel's HTML from a given SafeHtml object. Similar to HTMLPanel(String)

Parameters
safeHtml the html to set.

public HTMLPanel (String tag, 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

Public Methods

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.

Parameters
widget the widget to be added
elem the element within which it will be contained

public void add (Widget widget, 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

public void add (Widget widget)

Adds a child widget to the panel.

Parameters
widget the widget to be added

public void addAndReplaceElement (Widget widget, Element toReplace)

This method is deprecated.
use addAndReplaceElement(Widget, Element)

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

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

public void addAndReplaceElement (Widget widget, 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

public static 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

public Element getElementById (String id)

Finds an element within this panel by its id. This method uses 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