com.extjs.gxt.ui.client.core
Class Template

java.lang.Object
  extended by com.extjs.gxt.ui.client.core.Template

public class Template
extends java.lang.Object

Represents an HTML fragment template. Templates can be precompiled for greater performance.


Constructor Summary
Template(java.lang.String html)
          Creates a new template with the given html.
 
Method Summary
 com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element el, java.lang.Object... values)
          Applies the supplied values to the template and appends the new node(s) to el.
 com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element el, Params values)
          Applies the supplied values to the template and appends the new node(s) to el.
 java.lang.String applyTemplate(com.google.gwt.core.client.JavaScriptObject values)
          Returns an HTML fragment of this template with the specified values applied.
 java.lang.String applyTemplate(Params values)
          Returns an HTML fragment of this template with the specified values applied.
 void compile()
          Compiles the template into an internal function, eliminating the regex overhead.
 com.google.gwt.user.client.Element create(java.lang.Object... values)
          Creates a new element.
 com.google.gwt.user.client.Element create(Params values)
          Creates a new element.
 java.lang.String getHtml()
           
 ModelStringProvider<ModelData> getStringProvider()
          Returns the template's string provider.
 com.google.gwt.user.client.Element insert(com.google.gwt.user.client.Element el, int index, Params values)
          Applies the supplied values to the template and inserts the new node(s) at the given index.
 com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element el, Params params)
          Applies the supplied values to the template and inserts the new node(s) after el.
 com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element el, Params values)
          Applies the supplied values to the template and inserts the new node(s) before el.
 com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element el, Params values)
          Applies the supplied values to the template and inserts the new node(s) as the first child of el.
 com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element el, com.google.gwt.core.client.JavaScriptObject values)
          Applies the supplied values to the template and overwrites the content of el with the new node(s).
 com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element el, Params values)
          Applies the supplied values to the template and overwrites the content of el with the new node(s).
 void set(java.lang.String html, boolean compile)
          Sets the HTML used as the template and optionally compiles it.
 void setStringProvider(ModelStringProvider<ModelData> stringProvider)
          Sets the string provider for the template.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Template

public Template(java.lang.String html)
Creates a new template with the given html.

Parameters:
html - the HTML fragment or an array
Method Detail

append

public com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element el,
                                                 java.lang.Object... values)
Applies the supplied values to the template and appends the new node(s) to el.

Parameters:
el - the context element
values - the positional template values
Returns:
the new element

append

public com.google.gwt.user.client.Element append(com.google.gwt.user.client.Element el,
                                                 Params values)
Applies the supplied values to the template and appends the new node(s) to el.

Parameters:
el - the context element
values - the template values
Returns:
the new element

applyTemplate

public java.lang.String applyTemplate(com.google.gwt.core.client.JavaScriptObject values)
Returns an HTML fragment of this template with the specified values applied.

Parameters:
values - the substitution values
Returns:
the html frament

applyTemplate

public java.lang.String applyTemplate(Params values)
Returns an HTML fragment of this template with the specified values applied.

Parameters:
values - the values
Returns:
the html fragment

compile

public void compile()
Compiles the template into an internal function, eliminating the regex overhead.


create

public com.google.gwt.user.client.Element create(java.lang.Object... values)
Creates a new element.

Parameters:
values - the substitution values
Returns:
the new element

create

public com.google.gwt.user.client.Element create(Params values)
Creates a new element.

Parameters:
values - the substitution values
Returns:
the new element

getHtml

public java.lang.String getHtml()

getStringProvider

public ModelStringProvider<ModelData> getStringProvider()
Returns the template's string provider.

Returns:
the string provider

insert

public com.google.gwt.user.client.Element insert(com.google.gwt.user.client.Element el,
                                                 int index,
                                                 Params values)
Applies the supplied values to the template and inserts the new node(s) at the given index.

Parameters:
el - the context element
index - the insert index
values - the values
Returns:
the new element

insertAfter

public com.google.gwt.user.client.Element insertAfter(com.google.gwt.user.client.Element el,
                                                      Params params)
Applies the supplied values to the template and inserts the new node(s) after el.

Parameters:
el - the context element
params - the values
Returns:
the new element

insertBefore

public com.google.gwt.user.client.Element insertBefore(com.google.gwt.user.client.Element el,
                                                       Params values)
Applies the supplied values to the template and inserts the new node(s) before el.

Parameters:
el - the context element
values - the values
Returns:
the new element

insertFirst

public com.google.gwt.user.client.Element insertFirst(com.google.gwt.user.client.Element el,
                                                      Params values)
Applies the supplied values to the template and inserts the new node(s) as the first child of el.

Parameters:
el - the context element
values - the values
Returns:
the new element

overwrite

public com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element el,
                                                    Params values)
Applies the supplied values to the template and overwrites the content of el with the new node(s).

Parameters:
el - the context element
values - the values
Returns:
the new element

overwrite

public com.google.gwt.user.client.Element overwrite(com.google.gwt.user.client.Element el,
                                                    com.google.gwt.core.client.JavaScriptObject values)
Applies the supplied values to the template and overwrites the content of el with the new node(s).

Parameters:
el - the context element
values - the values
Returns:
the new element

set

public void set(java.lang.String html,
                boolean compile)
Sets the HTML used as the template and optionally compiles it.

Parameters:
html - the html fragment
compile - true to compile

setStringProvider

public void setStringProvider(ModelStringProvider<ModelData> stringProvider)
Sets the string provider for the template.

Parameters:
stringProvider - the string provider