com.itmill.toolkit.terminal.web
Class AjaxPaintTarget

java.lang.Object
  extended by com.itmill.toolkit.terminal.web.AjaxPaintTarget
All Implemented Interfaces:
PaintTarget

public class AjaxPaintTarget
extends Object
implements PaintTarget

User Interface Description Language Target.

Since:
3.1
Version:
4.1.4
Author:
IT Mill Ltd.

Constructor Summary
AjaxPaintTarget(AjaxVariableMap variableMap, AjaxApplicationManager manager, OutputStream output)
          Creates a new XMLPrintWriter, without automatic line flushing.
 
Method Summary
 void addAttribute(String name, boolean value)
          Adds a boolean attribute to component.
 void addAttribute(String name, int value)
          Adds a integer attribute to component.
 void addAttribute(String name, long value)
          Adds a long attribute to component.
 void addAttribute(String name, Resource value)
          Adds a resource attribute to component.
 void addAttribute(String name, String value)
          Adds a string attribute to component.
 void addCharacterData(String text)
          Adds CDATA node to target UIDL-tree.
 void addSection(String sectionTagName, String sectionData)
          Prints the single text section.
 void addText(String str)
          Prints XML-escaped text.
 void addUIDL(String xml)
          Adds XML directly to UIDL.
 void addUploadStreamVariable(VariableOwner owner, String name)
          Adds a upload stream type variable.
 void addVariable(VariableOwner owner, String name, boolean value)
          Adds a boolean type variable.
 void addVariable(VariableOwner owner, String name, int value)
          Adds a int type variable.
 void addVariable(VariableOwner owner, String name, String value)
          Adds a string type variable.
 void addVariable(VariableOwner owner, String name, String[] value)
          Adds a string array type variable.
 void addXMLSection(String sectionTagName, String sectionData, String namespace)
          Adds XML section with namespace.
 void close()
          Closes the paint target.
 void endTag(String tagName)
          Prints the element end tag.
static String escapeXML(String xml)
          Substitutes the XML sensitive characters with predefined XML entities.
static StringBuffer escapeXML(StringBuffer xml)
          Substitutes the XML sensitive characters with predefined XML entities.
 int getNumberOfPaints()
          Gets the number of paints.
 String getUIDL()
          Gets the UIDL already printed to stream.
 boolean isTrackPaints()
           
 void setTrackPaints(boolean enabled)
          Sets the tracking to true or false.
 boolean startTag(Paintable paintable, String tag)
          Prints element start tag of a paintable section.
 void startTag(String tagName)
          Prints the element start tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AjaxPaintTarget

public AjaxPaintTarget(AjaxVariableMap variableMap,
                       AjaxApplicationManager manager,
                       OutputStream output)
                throws PaintException
Creates a new XMLPrintWriter, without automatic line flushing.

Parameters:
variableMap -
manager -
output - A character-output stream.
Throws:
PaintException - if the paint operation failed.
Method Detail

startTag

public void startTag(String tagName)
              throws PaintException
Prints the element start tag.
 Todo:
  Checking of input values
  
 

Specified by:
startTag in interface PaintTarget
Parameters:
tagName - the name of the start tag.
Throws:
PaintException - if the paint operation failed.

endTag

public void endTag(String tagName)
            throws PaintException
Prints the element end tag. If the parent tag is closed before every child tag is closed an PaintException is raised.

Specified by:
endTag in interface PaintTarget
Parameters:
tag - the name of the end tag.
Throws:
Paintexception - if the paint operation failed.
PaintException - if the paint operation failed.

escapeXML

public static String escapeXML(String xml)
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

public static StringBuffer escapeXML(StringBuffer xml)
Substitutes the XML sensitive characters with predefined XML entities.

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

addText

public void addText(String str)
             throws PaintException
Prints XML-escaped text.

Specified by:
addText in interface PaintTarget
Parameters:
str -
Throws:
PaintException - if the paint operation failed.

addAttribute

public void addAttribute(String name,
                         boolean value)
                  throws PaintException
Adds a boolean attribute to component. Atributes must be added before any content is written.

Specified by:
addAttribute in interface PaintTarget
Parameters:
name - the Attribute name.
value - the Attribute value.
Throws:
PaintException - if the paint operation failed.

addAttribute

public void addAttribute(String name,
                         Resource value)
                  throws PaintException
Adds a resource attribute to component. Atributes must be added before any content is written.

Specified by:
addAttribute in interface PaintTarget
Parameters:
name - the Attribute name.
value - the Attribute value.
Throws:
PaintException - if the paint operation failed.

addAttribute

public void addAttribute(String name,
                         int value)
                  throws PaintException
Adds a integer attribute to component. Atributes must be added before any content is written.

Specified by:
addAttribute in interface PaintTarget
Parameters:
name - the Attribute name.
value - the Attribute value.
Throws:
PaintException - if the paint operation failed.

addAttribute

public void addAttribute(String name,
                         long value)
                  throws PaintException
Adds a long attribute to component. Atributes must be added before any content is written.

Specified by:
addAttribute in interface PaintTarget
Parameters:
name - the Attribute name.
value - the Attribute value.
Throws:
PaintException - if the paint operation failed.

addAttribute

public void addAttribute(String name,
                         String value)
                  throws PaintException
Adds a string attribute to component. Atributes must be added before any content is written.

Specified by:
addAttribute in interface PaintTarget
Parameters:
name - the Boolean attribute name.
value - the Boolean attribute value.
Throws:
PaintException - if the paint operation failed.

addVariable

public void addVariable(VariableOwner owner,
                        String name,
                        String value)
                 throws PaintException
Adds a string type variable.

Specified by:
addVariable in interface PaintTarget
Parameters:
owner - the Listener for variable changes.
name - the Variable name.
value - the Variable initial value.
Throws:
PaintException - if the paint operation failed.

addVariable

public void addVariable(VariableOwner owner,
                        String name,
                        int value)
                 throws PaintException
Adds a int type variable.

Specified by:
addVariable in interface PaintTarget
Parameters:
owner - the Listener for variable changes.
name - the Variable name.
value - the Variable initial value.
Throws:
PaintException - if the paint operation failed.

addVariable

public void addVariable(VariableOwner owner,
                        String name,
                        boolean value)
                 throws PaintException
Adds a boolean type variable.

Specified by:
addVariable in interface PaintTarget
Parameters:
owner - the Listener for variable changes.
name - the Variable name.
value - the Variable initial value.
Throws:
PaintException - if the paint operation failed.

addVariable

public void addVariable(VariableOwner owner,
                        String name,
                        String[] value)
                 throws PaintException
Adds a string array type variable.

Specified by:
addVariable in interface PaintTarget
Parameters:
owner - the Listener for variable changes.
name - the Variable name.
value - the Variable initial value.
Throws:
PaintException - if the paint operation failed.

addUploadStreamVariable

public void addUploadStreamVariable(VariableOwner owner,
                                    String name)
                             throws PaintException
Adds a upload stream type variable.

Specified by:
addUploadStreamVariable in interface PaintTarget
Parameters:
owner - the Listener for variable changes.
name - the Variable name.
Throws:
PaintException - if the paint operation failed.

addSection

public void addSection(String sectionTagName,
                       String sectionData)
                throws PaintException
Prints the single text section. Prints full text section. The section data is escaped from XML tags and surrounded by XML start and end-tags.

Specified by:
addSection in interface PaintTarget
Parameters:
sectionTagName - the name of the tag.
sectionData - the section data to be printed.
Throws:
PaintException - if the paint operation failed.

addUIDL

public void addUIDL(String xml)
             throws PaintException
Adds XML directly to UIDL.

Specified by:
addUIDL in interface PaintTarget
Parameters:
xml - the Xml to be added.
Throws:
PaintException - if the paint operation failed.

addXMLSection

public void addXMLSection(String sectionTagName,
                          String sectionData,
                          String namespace)
                   throws PaintException
Adds XML section with namespace.

Specified by:
addXMLSection in interface PaintTarget
Parameters:
sectionTagName - the name of the tag.
sectionData - the section data.
namespace - the namespace to be added.
Throws:
PaintException - if the paint operation failed.
See Also:
PaintTarget.addXMLSection(String, String, String)

getUIDL

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

Returns:
the UIDL.

close

public void close()
           throws PaintException
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.

Throws:
PaintException - if the paint operation failed.

startTag

public boolean startTag(Paintable paintable,
                        String tag)
                 throws PaintException
Description copied from interface: PaintTarget
Prints element start tag of a paintable section. Starts a paintable section using the given tag. The PaintTarget may implement a caching scheme, that checks the paintable has actually changed or can a cached version be used instead. This method should call the startTag method.

If the Paintable is found in cache and this function returns true it may omit the content and close the tag, in which case cached content should be used.

Specified by:
startTag in interface PaintTarget
Parameters:
paintable - the paintable to start.
tag - the name of the start tag.
Returns:
true if paintable found in cache, false otherwise.
Throws:
PaintException - if the paint operation failed.
See Also:
PaintTarget.startTag(com.itmill.toolkit.terminal.Paintable, java.lang.String)

addCharacterData

public void addCharacterData(String text)
                      throws PaintException
Description copied from interface: PaintTarget
Adds CDATA node to target UIDL-tree.

Specified by:
addCharacterData in interface PaintTarget
Parameters:
text - the Character data to add
Throws:
PaintException - if the paint operation failed.
See Also:
PaintTarget.addCharacterData(java.lang.String)

isTrackPaints

public boolean isTrackPaints()
Returns:

getNumberOfPaints

public int getNumberOfPaints()
Gets the number of paints.

Returns:
the number of paints.

setTrackPaints

public void setTrackPaints(boolean enabled)
Sets the tracking to true or false. This also resets the number of paints.

Parameters:
enabled - is the tracking is enabled or not.
See Also:
getNumberOfPaints()


Copyright © 2000-2008 IT Mill Ltd. All Rights Reserved.