Package muntjac :: Package terminal :: Package gwt :: Package server :: Module json_paint_target :: Class JsonPaintTarget
[hide private]
[frames] | no frames]

Class JsonPaintTarget

source code

               object --+    
                        |    
paint_target.IPaintTarget --+
                            |
                           JsonPaintTarget

User Interface Description Language Target.

TODO: document better: role of this class, UIDL format, attributes, variables, etc.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, manager, outWriter, cachingRequired)
Creates a new XMLPrintWriter, without automatic line flushing.
source code
 
startTag(self, arg, arg2=False)
Prints the element start tag.
source code
 
endTag(self, tagName)
Prints the element end tag.
source code
 
addText(self, s)
Prints XML-escaped text.
source code
 
addAttribute(self, name, value)
Adds a boolean attribute to component.
source code
 
addVariable(self, owner, name, value)
Adds details about StreamVariable to the UIDL stream.
source code
 
addUploadStreamVariable(self, owner, name)
Adds a upload stream type variable.
source code
 
addSection(self, sectionTagName, sectionData)
Prints the single text section.
source code
 
addUIDL(self, xml)
Adds XML directly to UIDL.
source code
 
addXMLSection(self, sectionTagName, sectionData, namespace)
Adds XML section with namespace.
source code
 
getUIDL(self)
Gets the UIDL already printed to stream.
source code
 
close(self)
Closes the paint target.
source code
 
flush(self)
Method flush.
source code
 
paintReference(self, paintable, referenceName)
Paints a component reference as an attribute to current tag.
source code
 
getPaintIdentifier(self, paintable) source code
 
addCharacterData(self, text)
Adds CDATA node to target UIDL-tree.
source code
 
getUsedResources(self) source code
 
needsToBePainted(self, p)
Method to check if paintable is already painted into this target.
source code
 
getTag(self, paintable)
Returns: the "tag" string used in communication to present given IPaintable type.
source code
 
hasClientWidgetMapping(self, class1) source code
 
getUsedPaintableTypes(self) source code
 
isFullRepaint(self)
@see PaintTarget.isFullRepaint
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
escapeXML(cls, xml)
Substitutes the XML sensitive characters with predefined XML entities.
source code
 
_escapeXML(cls, xml)
Substitutes the XML sensitive characters with predefined XML entities.
source code
 
escapeJSON(cls, s)
Escapes the given string so it can safely be used as a JSON string.
source code
 
toXmlChar(cls, c)
Substitutes a XML sensitive character with predefined XML entity.
source code
Static Methods [hide private]
 
_default(ch, sb) source code
Class Variables [hide private]
  _UIDL_ARG_NAME = 'name'
  _json_map = {'"': lambda ch, sb: sb.write('\\\"'), '\\': lambd...
  _widgetMappingCache = {}
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, manager, outWriter, cachingRequired)
(Constructor)

source code 

Creates a new XMLPrintWriter, without automatic line flushing.

Parameters:
  • manager
  • outWriter - A character-output stream.
  • cachingRequired - True if this is not a full repaint, i.e. caches are to be used.
Raises:
Overrides: object.__init__

startTag(self, arg, arg2=False)

source code 

Prints the element start tag.

Parameters:
  • arg - paintable or the name of the start tag
  • arg2 - the name of the start tag for the given paintable
Returns:
True if paintable found in cache, False otherwise.
Raises:
Overrides: paint_target.IPaintTarget.startTag

endTag(self, tagName)

source code 

Prints the element end tag.

If the parent tag is closed before every child tag is closed an PaintException is raised.

Parameters:
  • tagName - the name of the end tag.
Raises:
  • Paintexception - if the paint operation failed.
Overrides: paint_target.IPaintTarget.endTag

escapeXML(cls, xml)
Class Method

source code 

Substitutes the XML sensitive characters with predefined XML entities.

Parameters:
  • xml - the string to be substituted.
Returns:
A new string instance where all occurrences of XML sensitive characters are substituted with entities.

_escapeXML(cls, xml)
Class Method

source code 

Substitutes the XML sensitive characters with predefined XML entities.

Parameters:
  • xml - the string to be substituted.
Returns:
A new StringBuilder instance where all occurrences of XML sensitive characters are substituted with entities.

escapeJSON(cls, s)
Class Method

source code 

Escapes the given string so it can safely be used as a JSON string.

Parameters:
  • s - The string to escape
Returns:
Escaped version of the string

toXmlChar(cls, c)
Class Method

source code 

Substitutes a XML sensitive character with predefined XML entity.

Parameters:
  • c - the character to be replaced with an entity.
Returns:
String of the entity or null if character is not to be replaced with an entity.

addText(self, s)

source code 

Prints XML-escaped text.

Parameters:
  • text - the Text to add
Raises:
Overrides: paint_target.IPaintTarget.addText

addAttribute(self, name, value)

source code 

Adds a boolean attribute to component. Attributes must be added before any content is written.

Raises:
Overrides: paint_target.IPaintTarget.addAttribute
(inherited documentation)

addVariable(self, owner, name, value)

source code 

Adds details about StreamVariable to the UIDL stream. Eg. in web terminals Receivers are typically rendered for the client side as URLs, where the client side implementation can do an http post request.

The urls in UIDL message may use Muntjac specific protocol. Before actually using the urls on the client side, they should be passed via ApplicationConnection.translateMuntjacUri.

Note that in current terminal implementation StreamVariables are cleaned from the terminal only when:

  • a StreamVariable with same name replaces an old one
  • the variable owner is no more attached
  • the developer signals this by calling StreamingStartEvent.disposeStreamVariable

Most commonly a component developer can just ignore this issue, but with strict memory requirements and lots of StreamVariables implementations that reserve a lot of memory this may be a critical issue.

Parameters:
  • args - tuple of the form
    • (owner, name, value)
      1. the ReceiverOwner that can track the progress of streaming to the given StreamVariable
      2. an identifying name for the StreamVariable
      3. the StreamVariable to paint
Raises:
Overrides: paint_target.IPaintTarget.addVariable
(inherited documentation)

addUploadStreamVariable(self, owner, name)

source code 

Adds a upload stream type variable.

Parameters:
  • owner - the Listener for variable changes.
  • name - the Variable name.
Raises:
Overrides: paint_target.IPaintTarget.addUploadStreamVariable

addSection(self, sectionTagName, sectionData)

source code 

Prints the single text section.

Prints full text section. The section data is escaped

Parameters:
  • sectionTagName - the name of the tag.
  • sectionData - the section data to be printed.
Raises:
Overrides: paint_target.IPaintTarget.addSection

addUIDL(self, xml)

source code 

Adds XML directly to UIDL.

Parameters:
  • xml - the Xml to be added.
Raises:
Overrides: paint_target.IPaintTarget.addUIDL

addXMLSection(self, sectionTagName, sectionData, namespace)

source code 

Adds XML section with namespace.

Parameters:
  • sectionTagName - the name of the tag.
  • sectionData - the section data.
  • namespace - the namespace to be added.
Raises:
Overrides: paint_target.IPaintTarget.addXMLSection

getUIDL(self)

source code 

Gets the UIDL already printed to stream. Paint target must be closed before the getUIDL can be called.

Returns:
the UIDL.

close(self)

source code 

Closes the paint target. Paint target must be closed before the getUIDL 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.

Raises:

paintReference(self, paintable, referenceName)

source code 

Paints a component reference as an attribute to current tag. This method is meant to enable component interactions on client side. With reference the client side component can communicate directly to other component.

Note! This was experimental api and got replaced by addAttribute.

Parameters:
  • paintable - the Paintable to reference
  • referenceName - @raise PaintException
Overrides: paint_target.IPaintTarget.paintReference
(inherited documentation)

addCharacterData(self, text)

source code 

Adds CDATA node to target UIDL-tree.

Parameters:
  • text - the Character data to add
Raises:
Overrides: paint_target.IPaintTarget.addCharacterData
(inherited documentation)

needsToBePainted(self, p)

source code 

Method to check if paintable is already painted into this target.

Returns:
true if is not yet painted into this target and is connected to app

getTag(self, paintable)

source code 
Returns:
the "tag" string used in communication to present given IPaintable type. Terminal may define how to present paintable.
Overrides: paint_target.IPaintTarget.getTag
(inherited documentation)

isFullRepaint(self)

source code 

@see PaintTarget.isFullRepaint

Overrides: paint_target.IPaintTarget.isFullRepaint

Class Variable Details [hide private]

_json_map

Value:
{'"': lambda ch, sb: sb.write('\\\"'), '\\': lambda ch, sb: sb.write('\
\\\\'), '\b': lambda ch, sb: sb.write('\\b'), '\f': lambda ch, sb: sb.\
write('\\f'), '\n': lambda ch, sb: sb.write('\\n'), '\r': lambda ch, s\
b: sb.write('\\r'), '\t': lambda ch, sb: sb.write('\\t'), '/': lambda \
ch, sb: sb.write('\\/')}