com.vaadin.client.

Class UIDL

  • java.lang.Object
    • com.google.gwt.core.client.JavaScriptObject
      • com.vaadin.client.UIDL
  • All Implemented Interfaces:

    Iterable<Object>

    public final class UIDL
    extends com.google.gwt.core.client.JavaScriptObject
    implements Iterable<Object>

    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(), iterator() 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.

    • Constructor Detail

      • UIDL

        protected UIDL()
    • Method Detail

      • getId

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

        Returns:

        the value of the id attribute, if available

      • getTag

        public String getTag()

        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().

        Returns:

        the name for this section

      • getStringAttribute

        public String getStringAttribute​(String name)

        Gets the named attribute as a String.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • getAttributeNames

        public Set<String> getAttributeNames()

        Gets the names of the attributes available.

        Returns:

        the names of available attributes

      • getVariableNames

        public Set<String> getVariableNames()

        Gets the names of variables available.

        Returns:

        the names of available variables

      • getIntAttribute

        public int getIntAttribute​(String name)

        Gets the named attribute as an int.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • getLongAttribute

        public long getLongAttribute​(String name)

        Gets the named attribute as a long.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • getFloatAttribute

        public float getFloatAttribute​(String name)

        Gets the named attribute as a float.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • getDoubleAttribute

        public double getDoubleAttribute​(String name)

        Gets the named attribute as a double.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • getBooleanAttribute

        public boolean getBooleanAttribute​(String name)

        Gets the named attribute as a boolean.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • getMapAttribute

        public ValueMap getMapAttribute​(String name)

        Gets the named attribute as a Map of named values (key/value pairs).

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute Map

      • getStringArrayAttribute

        public String[] getStringArrayAttribute​(String name)

        Gets the named attribute as an array of Strings.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • getIntArrayAttribute

        public int[] getIntArrayAttribute​(String name)

        Gets the named attribute as an int array.

        Parameters:

        name - the name of the attribute to get

        Returns:

        the attribute value

      • hasAttribute

        public boolean hasAttribute​(String name)

        Indicates whether or not the named attribute is available.

        Parameters:

        name - the name of the attribute to check

        Returns:

        true if the attribute is available, false otherwise

      • getChildUIDL

        public UIDL getChildUIDL​(int i)

        Gets the UIDL for the child at the given index.

        Parameters:

        i - the index of the child to get

        Returns:

        the UIDL of the child if it exists

      • getChildString

        public String getChildString​(int i)

        Gets the child at the given index as a String.

        Parameters:

        i - the index of the child to get

        Returns:

        the String representation of the child if it exists

      • getChildIterator

        @Deprecated
        public Iterator<Object> getChildIterator()
        Deprecated.
        As of 8.2, please use iterator() instead

        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.

        Returns:

        an iterator for iterating over UIDL children

      • iterator

        public Iterator<Object> iterator()

        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.

        Specified by:

        iterator in interface Iterable<Object>

        Returns:

        an iterator for iterating over UIDL children

        Since:

        8.2

      • hasVariable

        public boolean hasVariable​(String name)

        Checks if the named variable is available.

        Parameters:

        name - the name of the variable desired

        Returns:

        true if the variable exists, false otherwise

      • getStringVariable

        public String getStringVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getIntVariable

        public int getIntVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getLongVariable

        public long getLongVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getFloatVariable

        public float getFloatVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getDoubleVariable

        public double getDoubleVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getBooleanVariable

        public boolean getBooleanVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getStringArrayVariable

        public String[] getStringArrayVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getStringArrayVariableAsSet

        public Set<String> getStringArrayVariableAsSet​(String name)

        Gets the value of the named String[] variable as a Set of Strings.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getIntArrayVariable

        public int[] getIntArrayVariable​(String name)

        Gets the value of the named variable.

        Parameters:

        name - the name of the variable

        Returns:

        the value of the variable

      • getChildCount

        public int getChildCount()

        Returns the number of children.

        Returns:

        the number of children

      • getPaintableAttribute

        public ServerConnector getPaintableAttribute​(String name,
                                                     ApplicationConnection connection)

        Gets the Paintable with the id found in the named attributes's value.

        Parameters:

        name - the name of the attribute

        Returns:

        the Paintable referenced by the attribute, if it exists

      • getPaintableVariable

        public ServerConnector getPaintableVariable​(String name,
                                                    ApplicationConnection connection)

        Gets the Paintable with the id found in the named variable's value.

        Parameters:

        name - the name of the variable

        Returns:

        the Paintable referenced by the variable, if it exists

      • getChildByTagName

        public UIDL getChildByTagName​(String tagName)

        Returns the child UIDL by its name. If several child nodes exist with the given name, the first child UIDL will be returned.

        Parameters:

        tagName -

        Returns:

        the child UIDL or null if child wit given name was not found