com.vaadin.terminal.gwt.client.
Class UIDL
java.lang.Object
com.google.gwt.core.client.JavaScriptObject
com.vaadin.terminal.gwt.client.UIDL
- extends com.google.gwt.core.client.JavaScriptObject
public final class UIDL
When a component is updated, it's client side widget's
updateFromUIDL()
will be called with the updated ("changes") UIDL received
from the server.
UIDL is hierarchical, and there are a few methods to retrieve the children,
getChildCount()
, getChildIterator()
getChildString(int)
, getChildUIDL(int)
.
It can be helpful to keep in mind that UIDL was originally modeled in XML, so it's structure is very XML -like. For instance, the first to children in the underlying UIDL representation will contain the "tag" name and attributes, but will be skipped by the methods mentioned above.
Nested Class Summary | |
---|---|
static class |
UIDL.XML
Deprecated. should not be used anymore |
Constructor Summary | |
---|---|
protected |
UIDL()
|
Method Summary | |
---|---|
Set<String> |
getAttributeNames()
Gets the names of the attributes available. |
boolean |
getBooleanAttribute(String name)
Gets the named attribute as a boolean. |
boolean |
getBooleanVariable(String name)
Gets the value of the named variable. |
UIDL |
getChildByTagName(String tagName)
Returns the child UIDL by its name. |
int |
getChildCount()
Returns the number of children. |
Iterator<Object> |
getChildIterator()
Gets an iterator that can be used to iterate trough the children of this UIDL. |
String |
getChildrenAsXML()
Deprecated. |
String |
getChildString(int i)
Gets the child at the given index as a String. |
UIDL |
getChildUIDL(int i)
Gets the UIDL for the child at the given index. |
double |
getDoubleAttribute(String name)
Gets the named attribute as a double. |
double |
getDoubleVariable(String name)
Gets the value of the named variable. |
UIDL |
getErrors()
Shorthand that returns the component errors as UIDL. |
float |
getFloatAttribute(String name)
Gets the named attribute as a float. |
float |
getFloatVariable(String name)
Gets the value of the named variable. |
String |
getId()
Shorthand for getting the attribute named "id", which for Paintables is the essential paintableId which binds the server side component to the client side widget. |
int[] |
getIntArrayAttribute(String name)
Gets the named attribute as an int array. |
int[] |
getIntArrayVariable(String name)
Gets the value of the named variable. |
int |
getIntAttribute(String name)
Gets the named attribute as an int. |
int |
getIntVariable(String name)
Gets the value of the named variable. |
long |
getLongAttribute(String name)
Gets the named attribute as a long. |
long |
getLongVariable(String name)
Gets the value of the named variable. |
ValueMap |
getMapAttribute(String name)
Gets the named attribute as a Map of named values (key/value pairs). |
Paintable |
getPaintableAttribute(String name,
ApplicationConnection connection)
Gets the Paintable with the id found in the named attributes's value. |
Paintable |
getPaintableVariable(String name,
ApplicationConnection connection)
Gets the Paintable with the id found in the named variable's value. |
String[] |
getStringArrayAttribute(String name)
Gets the named attribute as an array of Strings. |
String[] |
getStringArrayVariable(String name)
Gets the value of the named variable. |
Set<String> |
getStringArrayVariableAsSet(String name)
Gets the value of the named String[] variable as a Set of Strings. |
String |
getStringAttribute(String name)
Gets the named attribute as a String. |
String |
getStringVariable(String name)
Gets the value of the named variable. |
String |
getTag()
Gets the name of this UIDL section, as created with PaintTarget.startTag() in the
server-side Component.paint() or
(usually) AbstractComponent.paintContent() . |
Set<String> |
getVariableNames()
Gets the names of variables available. |
boolean |
hasAttribute(String name)
Indicates whether or not the named attribute is available. |
boolean |
hasVariable(String name)
Checks if the named variable is available. |
Methods inherited from class com.google.gwt.core.client.JavaScriptObject |
---|
cast, createArray, createFunction, createObject, equals, hashCode, toSource, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
UIDL
protected UIDL()
Method Detail |
---|
getId
public String getId()
- Returns:
- the value of the id attribute, if available
Shorthand for getting the attribute named "id", which for Paintables is the essential paintableId which binds the server side component to the client side widget.
getTag
public String getTag()
- Returns:
- the name for this section
Gets the name of this UIDL section, as created with
PaintTarget.startTag()
in the
server-side Component.paint()
or
(usually) AbstractComponent.paintContent()
. Note that if the UIDL corresponds to a
Paintable, a component identifier will be returned instead - this is used
internally and is not needed within
updateFromUIDL()
.
getStringAttribute
public String getStringAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as a String.
getAttributeNames
public Set<String> getAttributeNames()
- Returns:
- the names of available attributes
Gets the names of the attributes available.
getVariableNames
public Set<String> getVariableNames()
- Returns:
- the names of available variables
Gets the names of variables available.
getIntAttribute
public int getIntAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as an int.
getLongAttribute
public long getLongAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as a long.
getFloatAttribute
public float getFloatAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as a float.
getDoubleAttribute
public double getDoubleAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as a double.
getBooleanAttribute
public boolean getBooleanAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as a boolean.
getMapAttribute
public ValueMap getMapAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute Map
Gets the named attribute as a Map of named values (key/value pairs).
getStringArrayAttribute
public String[] getStringArrayAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as an array of Strings.
getIntArrayAttribute
public int[] getIntArrayAttribute(String name)
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value
Gets the named attribute as an int array.
hasAttribute
public boolean hasAttribute(String name)
- Parameters:
name
- the name of the attribute to check- Returns:
- true if the attribute is available, false otherwise
Indicates whether or not the named attribute is available.
getChildUIDL
public UIDL getChildUIDL(int i)
- Parameters:
i
- the index of the child to get- Returns:
- the UIDL of the child if it exists
Gets the UIDL for the child at the given index.
getChildString
public String getChildString(int i)
- Parameters:
i
- the index of the child to get- Returns:
- the String representation of the child if it exists
Gets the child at the given index as a String.
getChildIterator
public Iterator<Object> getChildIterator()
- Returns:
- an iterator for iterating over UIDL children
Gets an iterator that can be used to iterate trough the children of this UIDL.
The Object returned by next()
will be appropriately typed -
if it's UIDL, getTag()
can be used to check which section is in
question.
The basic use case is to iterate over the children of an UIDL update, and
update the appropriate part of the widget for each child encountered, e.g
if getTag()
returns "color", one would update the widgets
color to reflect the value of the "color" section.
getChildrenAsXML
@Deprecated
public String getChildrenAsXML()
Deprecated.
hasVariable
public boolean hasVariable(String name)
- Parameters:
name
- the name of the variable desired- Returns:
- true if the variable exists, false otherwise
Checks if the named variable is available.
getStringVariable
public String getStringVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getIntVariable
public int getIntVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getLongVariable
public long getLongVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getFloatVariable
public float getFloatVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getDoubleVariable
public double getDoubleVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getBooleanVariable
public boolean getBooleanVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getStringArrayVariable
public String[] getStringArrayVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getStringArrayVariableAsSet
public Set<String> getStringArrayVariableAsSet(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named String[] variable as a Set of Strings.
getIntArrayVariable
public int[] getIntArrayVariable(String name)
- Parameters:
name
- the name of the variable- Returns:
- the value of the variable
Gets the value of the named variable.
getChildCount
public int getChildCount()
- Returns:
- the number of children
Returns the number of children.
getErrors
public UIDL getErrors()
- Returns:
- the error UIDL if available
Shorthand that returns the component errors as UIDL. Only applicable for Paintables.
getPaintableAttribute
public Paintable getPaintableAttribute(String name,
ApplicationConnection connection)
- Parameters:
name
- the name of the attribute- Returns:
- the Paintable referenced by the attribute, if it exists
Gets the Paintable with the id found in the named attributes's value.
getPaintableVariable
public Paintable getPaintableVariable(String name,
ApplicationConnection connection)
- Parameters:
name
- the name of the variable- Returns:
- the Paintable referenced by the variable, if it exists
Gets the Paintable with the id found in the named variable's value.
getChildByTagName
public UIDL getChildByTagName(String tagName)
- Parameters:
tagName
-- Returns:
- the child UIDL or null if child wit given name was not found
Returns the child UIDL by its name. If several child nodes exist with the given name, the first child UIDL will be returned.