* is meant to enable component interactions on client side. With reference
* the client side component can communicate directly to other component.
*
- * Note! This is still an experimental feature and API is likely to change
- * in future.
+ * Note! This was experimental api and got replaced by
+ * {@link #addAttribute(String, Paintable)} and
+ * {@link #addVariable(VariableOwner, String, Paintable)}.
*
* @param paintable
* the Paintable to reference
* @throws PaintException
*
* @since 5.2
+ * @deprecated use {@link #addAttribute(String, Paintable)} or
+ * {@link #addVariable(VariableOwner, String, Paintable)}
+ * instead
*/
+ @Deprecated
public void paintReference(Paintable paintable, String referenceName)
throws PaintException;
public void addAttribute(String name, Map<?, ?> value)
throws PaintException;
+ /**
+ * Adds a Paintable type attribute. On client side the value will be a
+ * terminal specific reference to corresponding component on client side
+ * implementation.
+ *
+ * @param name
+ * the name of the attribute
+ * @param value
+ * the Paintable to be referenced on client side
+ * @throws PaintException
+ */
+ public void addAttribute(String name, Paintable value)
+ throws PaintException;
+
/**
* Adds a string type variable.
*
public void addVariable(VariableOwner owner, String name, String[] value)
throws PaintException;
+ /**
+ * Adds a Paintable type variable. On client side the variable value will be
+ * a terminal specific reference to corresponding component on client side
+ * implementation. When updated from client side, terminal will map the
+ * client side component reference back to a corresponding server side
+ * reference.
+ *
+ * @param owner
+ * the Listener for variable changes
+ * @param name
+ * the name of the variable
+ * @param value
+ * the initial value of the variable
+ *
+ * @throws PaintException
+ * if the paint oparation fails
+ */
+ public void addVariable(VariableOwner owner, String name, Paintable value)
+ throws PaintException;
+
/**
* Adds a upload stream type variable.
*
/**
* Creates a new XMLPrintWriter, without automatic line flushing.
- *
+ *
* @param variableMap
* @param manager
* @param outWriter
* @throws PaintException
* if the paint operation failed.
*/
- public JsonPaintTarget(AbstractCommunicationManager manager, PrintWriter outWriter,
- boolean cachingRequired) throws PaintException {
+ public JsonPaintTarget(AbstractCommunicationManager manager,
+ PrintWriter outWriter, boolean cachingRequired)
+ throws PaintException {
this.manager = manager;
/**
* Prints the element start tag.
- *
+ *
* <pre>
* Todo:
* Checking of input values
- *
+ *
* </pre>
- *
+ *
* @param tagName
* the name of the start tag.
* @throws PaintException
* if the paint operation failed.
- *
+ *
*/
public void startTag(String tagName, boolean isChildNode)
throws PaintException {
/**
* Prints the element end tag.
- *
+ *
* If the parent tag is closed before every child tag is closed an
* PaintException is raised.
- *
+ *
* @param tag
* the name of the end tag.
* @throws Paintexception
/**
* Substitutes the XML sensitive characters with predefined XML entities.
- *
+ *
* @param xml
* the String to be substituted.
* @return A new string instance where all occurrences of XML sensitive
/**
* Substitutes the XML sensitive characters with predefined XML entities.
- *
+ *
* @param xml
* the String to be substituted.
* @return A new StringBuilder instance where all occurrences of XML
* sensitive characters are substituted with entities.
- *
+ *
*/
static StringBuilder escapeXML(StringBuilder xml) {
if (xml == null || xml.length() <= 0) {
/**
* Substitutes a XML sensitive character with predefined XML entity.
- *
+ *
* @param c
* the Character to be replaced with an entity.
* @return String of the entity or null if character is not to be replaced
/**
* Prints XML-escaped text.
- *
+ *
* @param str
* @throws PaintException
* if the paint operation failed.
- *
+ *
*/
public void addText(String str) throws PaintException {
tag.addData("\"" + escapeJSON(str) + "\"");
}
- /**
- * Adds a boolean attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- * @throws PaintException
- * if the paint operation failed.
- */
public void addAttribute(String name, boolean value) throws PaintException {
tag.addAttribute("\"" + name + "\":" + (value ? "true" : "false"));
}
- /**
- * Adds a resource attribute to component. Attributes must be added before
- * any content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addAttribute(String name, Resource value) throws PaintException {
if (value instanceof ExternalResource) {
}
- /**
- * Adds a integer attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addAttribute(String name, int value) throws PaintException {
tag.addAttribute("\"" + name + "\":" + String.valueOf(value));
}
- /**
- * Adds a long attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addAttribute(String name, long value) throws PaintException {
tag.addAttribute("\"" + name + "\":" + String.valueOf(value));
}
- /**
- * Adds a float attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addAttribute(String name, float value) throws PaintException {
tag.addAttribute("\"" + name + "\":" + String.valueOf(value));
}
- /**
- * Adds a double attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the Attribute name.
- * @param value
- * the Attribute value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addAttribute(String name, double value) throws PaintException {
tag.addAttribute("\"" + name + "\":" + String.valueOf(value));
}
- /**
- * Adds a string attribute to component. Atributes must be added before any
- * content is written.
- *
- * @param name
- * the String attribute name.
- * @param value
- * the String attribute value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addAttribute(String name, String value) throws PaintException {
// In case of null data output nothing:
if ((value == null) || (name == null)) {
}
+ public void addAttribute(String name, Paintable value)
+ throws PaintException {
+ final String id = getPaintIdentifier(value);
+ addAttribute(name, id);
+ }
+
public void addAttribute(String name, Map<?, ?> value)
throws PaintException {
tag.addAttribute(buf.toString());
}
- /**
- * Adds a string type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addVariable(VariableOwner owner, String name, String value)
throws PaintException {
tag.addVariable(new StringVariable(owner, name, escapeJSON(value)));
}
- /**
- * Adds a int type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
+ public void addVariable(VariableOwner owner, String name, Paintable value)
+ throws PaintException {
+ tag.addVariable(new StringVariable(owner, name,
+ getPaintIdentifier(value)));
+ }
+
public void addVariable(VariableOwner owner, String name, int value)
throws PaintException {
tag.addVariable(new IntVariable(owner, name, value));
}
- /**
- * Adds a long type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addVariable(VariableOwner owner, String name, long value)
throws PaintException {
tag.addVariable(new LongVariable(owner, name, value));
}
- /**
- * Adds a float type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addVariable(VariableOwner owner, String name, float value)
throws PaintException {
tag.addVariable(new FloatVariable(owner, name, value));
}
- /**
- * Adds a double type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addVariable(VariableOwner owner, String name, double value)
throws PaintException {
tag.addVariable(new DoubleVariable(owner, name, value));
}
- /**
- * Adds a boolean type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addVariable(VariableOwner owner, String name, boolean value)
throws PaintException {
tag.addVariable(new BooleanVariable(owner, name, value));
}
- /**
- * Adds a string array type variable.
- *
- * @param owner
- * the Listener for variable changes.
- * @param name
- * the Variable name.
- * @param value
- * the Variable initial value.
- *
- * @throws PaintException
- * if the paint operation failed.
- */
public void addVariable(VariableOwner owner, String name, String[] value)
throws PaintException {
tag.addVariable(new ArrayVariable(owner, name, value));
/**
* Adds a upload stream type variable.
- *
+ *
* TODO not converted for JSON
- *
+ *
* @param owner
* the Listener for variable changes.
* @param name
* the Variable name.
- *
+ *
* @throws PaintException
* if the paint operation failed.
*/
/**
* Prints the single text section.
- *
+ *
* Prints full text section. The section data is escaped
- *
+ *
* @param sectionTagName
* the name of the tag.
* @param sectionData
/**
* Adds XML directly to UIDL.
- *
+ *
* @param xml
* the Xml to be added.
* @throws PaintException
/**
* Adds XML section with namespace.
- *
+ *
* @param sectionTagName
* the name of the tag.
* @param sectionData
* the namespace to be added.
* @throws PaintException
* if the paint operation failed.
- *
+ *
* @see com.vaadin.terminal.PaintTarget#addXMLSection(String, String,
* String)
*/
/**
* Gets the UIDL already printed to stream. Paint target must be closed
* before the <code>getUIDL</code> can be called.
- *
+ *
* @return the UIDL.
*/
public String getUIDL() {
* <code>getUIDL</code> can be called. Subsequent attempts to write to paint
* target. If the target was already closed, call to this function is
* ignored. will generate an exception.
- *
+ *
* @throws PaintException
* if the paint operation failed.
*/
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.terminal.PaintTarget#startTag(com.vaadin.terminal
* .Paintable, java.lang.String)
*/
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.terminal.PaintTarget#addCharacterData(java.lang.String )
*/
public void addCharacterData(String text) throws PaintException {
/**
* This is basically a container for UI components variables, that will be
* added at the end of JSON object.
- *
+ *
* @author mattitahvonen
- *
+ *
*/
class JsonTag implements Serializable {
boolean firstField = false;
}
/**
- *
+ *
* @param s
* json string, object or array
*/
/**
* Method to check if paintable is already painted into this target.
- *
+ *
* @param p
* @return true if is not yet painted into this target and is connected to
* app