com.gwtext.client.core
Class DomHelper

java.lang.Object
  extended by com.gwtext.client.core.DomHelper

public class DomHelper
extends java.lang.Object

Utility class for working with DOM and/or Templates. It transparently supports using HTML fragments or DOM.

This is an example, where an unordered list with 5 children items is appended to an existing element with id 'my-div':

 
 

DomConfig config = new DomConfig("ul", null, "my-list"); config.addChild(new DomConfig("li", "item0", null, "List Item 0")); config.addChild(new DomConfig("li", "item1", null, "List Item 1")); config.addChild(new DomConfig("li", "item2", null, "List Item 2")); config.addChild(new DomConfig("li", "item3", null, "List Item 3")); config.addChild(new DomConfig("li", "item4", null, "List Item 4"));

Element list = DomHelper.append("my-div", config);


Constructor Summary
DomHelper()
           
 
Method Summary
static com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element parent, DomConfig config)
          Creates new Dom element(s) and appends them to the parent element.
static com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element parent, com.google.gwt.user.client.Element child)
          Creates new Dom element(s) and appends them to the parent element.
static com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element parent, java.lang.String rawHtml)
          Creates new Dom element(s) and appends them to the parent element.
static com.google.gwt.user.client.Element append(java.lang.String parentId, DomConfig config)
          Creates new Dom element(s) and appends them to the parent element.
static com.google.gwt.user.client.Element append(java.lang.String parentId, java.lang.String rawHtml)
          Creates new Dom element(s) and appends them to the parent element.
static void applyStyles(com.google.gwt.user.client.Element element, java.lang.String styles)
          Applies a style specification to an element.
static Template createTemplate(DomConfig config)
          Creates a new Template from the Dom config spec.
static com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element elem, DomConfig config)
          Creates new Dom element(s) and inserts them after the specified element.
static com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element elem, com.google.gwt.user.client.Element sibling)
          Creates new Dom element and inserts them after the specified element.
static com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element elem, java.lang.String rawHtml)
          Creates new Dom element(s) and inserts them after the specified element.
static com.google.gwt.user.client.Element insertAfter(java.lang.String id, DomConfig config)
          Creates new Dom element(s) and inserts them after the specified element.
static com.google.gwt.user.client.Element insertAfter(java.lang.String id, java.lang.String rawHtml)
          Creates new Dom element(s) and inserts them after the specified element.
static com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element elem, DomConfig config)
          Creates new Dom element and inserts them before the specified element.
static com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element elem, com.google.gwt.user.client.Element sibling)
          Creates new Dom element and inserts them before the specified element.
static com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element elem, java.lang.String rawHtml)
          Creates new Dom element and inserts them before the specified element.
static com.google.gwt.user.client.Element insertBefore(java.lang.String id, DomConfig config)
          Creates new Dom element and inserts them before the specified element.
static com.google.gwt.user.client.Element insertBefore(java.lang.String id, java.lang.String rawHtml)
          Creates new Dom element and inserts them before the specified element.
static com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element parent, DomConfig config)
          Creates new Dom element(s) and inserts them as the first child of the parent element.
static com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element parent, com.google.gwt.user.client.Element child)
          Creates new Dom element(s) and inserts them as the first child of the parent element.
static com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element parent, java.lang.String rawHtml)
          Creates new Dom element(s) and inserts them as the first child of the parent element.
static com.google.gwt.user.client.Element insertFirst(java.lang.String parentId, DomConfig config)
          Creates new Dom element(s) and inserts them as the first child of the parent element.
static com.google.gwt.user.client.Element insertFirst(java.lang.String parentId, java.lang.String rawHtml)
          Creates new Dom element(s) and inserts them as the first child of the parent element.
static java.lang.String markup(DomConfig config)
          Returns the markup for the passed Element config.
static com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element oldElem, DomConfig config)
          Creates new Dom element(s) and overwrites the contents of the old element with them.
static com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element oldElem, com.google.gwt.user.client.Element newElem)
          Creates new Dom element(s) and overwrites the contents of the old element with them.
static com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element oldElem, java.lang.String newRawHtml)
          Creates new Dom element(s) and overwrites the contents of the old element with them.
static com.google.gwt.user.client.Element overwrite(java.lang.String oldId, DomConfig config)
          Creates new Dom element(s) and overwrites the contents of the old element with them.
static com.google.gwt.user.client.Element overwrite(java.lang.String oldId, java.lang.String newRawHtml)
          Creates new Dom element(s) and overwrites the contents of the old element with them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomHelper

public DomHelper()
Method Detail

append

public static com.google.gwt.user.client.Element append(java.lang.String parentId,
                                                        java.lang.String rawHtml)
Creates new Dom element(s) and appends them to the parent element.

Parameters:
parentId - the parent element id
rawHtml - raw html blob
Returns:
the new node

append

public static com.google.gwt.user.client.Element append(java.lang.String parentId,
                                                        DomConfig config)
Creates new Dom element(s) and appends them to the parent element.

Parameters:
parentId - the parent element id
config - child dom config
Returns:
the new node

append

public static com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element parent,
                                                        java.lang.String rawHtml)
Creates new Dom element(s) and appends them to the parent element.

Parameters:
parent - the parent element
rawHtml - raw html blob
Returns:
the new node

append

public static com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element parent,
                                                        DomConfig config)
Creates new Dom element(s) and appends them to the parent element.

Parameters:
parent - the parent element
config - child dom config
Returns:
the new node

append

public static com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element parent,
                                                        com.google.gwt.user.client.Element child)
Creates new Dom element(s) and appends them to the parent element.

Parameters:
parent - the parent element
child - child element
Returns:
the new node

applyStyles

public static void applyStyles(com.google.gwt.user.client.Element element,
                               java.lang.String styles)
Applies a style specification to an element.

Parameters:
element - the element to apply styles to
styles - a style specification string eg "width:100px"

createTemplate

public static Template createTemplate(DomConfig config)
Creates a new Template from the Dom config spec.

Parameters:
config - the dom config
Returns:
the new Template

insertAfter

public static com.google.gwt.user.client.Element insertAfter(java.lang.String id,
                                                             java.lang.String rawHtml)
Creates new Dom element(s) and inserts them after the specified element.

Parameters:
id - the element id
rawHtml - raw html blob
Returns:
the new node

insertAfter

public static com.google.gwt.user.client.Element insertAfter(java.lang.String id,
                                                             DomConfig config)
Creates new Dom element(s) and inserts them after the specified element.

Parameters:
id - the element id
config - the element dom config spec
Returns:
the new node

insertAfter

public static com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element elem,
                                                             java.lang.String rawHtml)
Creates new Dom element(s) and inserts them after the specified element.

Parameters:
elem - the element
rawHtml - the raw html blob
Returns:
the new node

insertAfter

public static com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element elem,
                                                             DomConfig config)
Creates new Dom element(s) and inserts them after the specified element.

Parameters:
elem - the element
config - the element dom config spec
Returns:
the new node

insertAfter

public static com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element elem,
                                                             com.google.gwt.user.client.Element sibling)
Creates new Dom element and inserts them after the specified element.

Parameters:
elem - the element
sibling - the sibling element
Returns:
the new node

insertBefore

public static com.google.gwt.user.client.Element insertBefore(java.lang.String id,
                                                              java.lang.String rawHtml)
Creates new Dom element and inserts them before the specified element.

Parameters:
id - the element id
rawHtml - the raw html blob
Returns:
the new node

insertBefore

public static com.google.gwt.user.client.Element insertBefore(java.lang.String id,
                                                              DomConfig config)
Creates new Dom element and inserts them before the specified element.

Parameters:
id - the element id
config - the dom config object
Returns:
the new node

insertBefore

public static com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element elem,
                                                              java.lang.String rawHtml)
Creates new Dom element and inserts them before the specified element.

Parameters:
elem - the element
rawHtml - the raw html blob
Returns:
the new node

insertBefore

public static com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element elem,
                                                              DomConfig config)
Creates new Dom element and inserts them before the specified element.

Parameters:
elem - the element
config - the dom config object
Returns:
the new node

insertBefore

public static com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element elem,
                                                              com.google.gwt.user.client.Element sibling)
Creates new Dom element and inserts them before the specified element.

Parameters:
elem - the element
sibling - the sibling element
Returns:
the new node

insertFirst

public static com.google.gwt.user.client.Element insertFirst(java.lang.String parentId,
                                                             java.lang.String rawHtml)
Creates new Dom element(s) and inserts them as the first child of the parent element.

Parameters:
parentId - the parent element id
rawHtml - raw html blob
Returns:
the new node

insertFirst

public static com.google.gwt.user.client.Element insertFirst(java.lang.String parentId,
                                                             DomConfig config)
Creates new Dom element(s) and inserts them as the first child of the parent element.

Parameters:
parentId - the parent element id
config - the child dom config object
Returns:
the new node

insertFirst

public static com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element parent,
                                                             java.lang.String rawHtml)
Creates new Dom element(s) and inserts them as the first child of the parent element.

Parameters:
parent - the parent element
rawHtml - raw html blob
Returns:
the new node

insertFirst

public static com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element parent,
                                                             DomConfig config)
Creates new Dom element(s) and inserts them as the first child of the parent element.

Parameters:
parent - the parent element
config - the child dom config object
Returns:
the new node

insertFirst

public static com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element parent,
                                                             com.google.gwt.user.client.Element child)
Creates new Dom element(s) and inserts them as the first child of the parent element.

Parameters:
parent - the parent element
child - the child element
Returns:
the new node

markup

public static java.lang.String markup(DomConfig config)
Returns the markup for the passed Element config.

Parameters:
config - the element config
Returns:
markup

overwrite

public static com.google.gwt.user.client.Element overwrite(java.lang.String oldId,
                                                           java.lang.String newRawHtml)
Creates new Dom element(s) and overwrites the contents of the old element with them.

Parameters:
oldId - the old element id
newRawHtml - raw html blob
Returns:
the new node

overwrite

public static com.google.gwt.user.client.Element overwrite(java.lang.String oldId,
                                                           DomConfig config)
Creates new Dom element(s) and overwrites the contents of the old element with them.

Parameters:
oldId - the old element id
config - the dom config object
Returns:
the new node

overwrite

public static com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element oldElem,
                                                           java.lang.String newRawHtml)
Creates new Dom element(s) and overwrites the contents of the old element with them.

Parameters:
oldElem - the old element
newRawHtml - raw html blob
Returns:
the new node

overwrite

public static com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element oldElem,
                                                           DomConfig config)
Creates new Dom element(s) and overwrites the contents of the old element with them.

Parameters:
oldElem - the old element
config - the dom config object
Returns:
the new node

overwrite

public static com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element oldElem,
                                                           com.google.gwt.user.client.Element newElem)
Creates new Dom element(s) and overwrites the contents of the old element with them.

Parameters:
oldElem - the old element
newElem - the new element
Returns:
the new node