Home » tapestry-src-5.0.19 » org.apache.tapestry5 » [javadoc | source]
public interface: MarkupWriter [javadoc | source]

All Known Implementing Classes:

An interface used by objects, such as Tapestry components, that need to render themselves as some form of XML markup. A markup writer maintains the idea of a current element. Attributes are added to the current element, and new text and elements are placed inside the current element. In this way, the markup writer maintains a facade that XML markup is generated as a stream, even though the implementation builds a kind of DOM tree. The DOM tree can be also be manipulated. This solves a number of problems from Tapestry 4 (and earlier) where random access to the DOM was desired and had to be simulated through complex buffering.
Method from org.apache.tapestry5.MarkupWriter Summary:
addListener,   attributeNS,   attributes,   cdata,   comment,   defineNamespace,   element,   elementNS,   end,   getDocument,   getElement,   removeListener,   toMarkup,   write,   writeRaw,   writef
Method from org.apache.tapestry5.MarkupWriter Detail:
 public  void addListener(MarkupWriterListener listener)
    Adds a markup writer listener that will be notified as elements are started and ended.
 public Element attributeNS(String namespace,
    String attributeName,
    String attributeValue)
    Creates an attribute within the namespace for the current element.
 public  void attributes(Object namesAndValues)
    Adds a series of attributes and values. Null values are quietly skipped. If a name already has a value, then the new value is ignored.
 public  void cdata(String content)
    Adds parsed character content. This will be enclosed in a CDATA block if supported. When not supported, this is the same as #write(String) .
 public  void comment(String text)
    Adds an XML comment. The text should be just the comment content, the comment delimiters will be provided.
 public Element defineNamespace(String namespace,
    String namespacePrefix)
    Defines a namespace for the currently active element. The namespace URI will be mapped to the provided namespace prefix within the Element.
 public Element element(String name,
    Object attributes)
    Begins a new element as a child of the current element. The new element becomes the current element. The new Element is returned and can be directly manipulated (possibly at a later date). Optionally, attributes for the new element can be specified directly.

 public Element elementNS(String namespace,
    String elementName)
    Starts an element within the given namespace. The correct namespace prefix will be identified and used. Must be balanced by a call to #end() .
 public Element end()
    Ends the current element. The new current element will be the parent element. Returns the new current element (which may be null when ending the root element for the document).
 public Document getDocument()
    Returns the Document into which this writer creates elements or other nodes.
 public Element getElement()
    Returns the currently active element.
 public  void removeListener(MarkupWriterListener listener)
    Removes a previously added listener.
 public  void toMarkup(PrintWriter writer)
    Converts the collected markup into an markup stream (according to rules provided by the Document 's MarkupModel ). The markup stream is sent to the writer.
 public  void write(String text)
    Writes the text as a child of the current element.
 public  void writeRaw(String text)
    Writes raw text, text with existing markup that should be passed through the client without change. This can be useful when the markup is read from an external source (a file or a database) and is simply to be included.
 public  void writef(String format,
    Object args)
    Writes a formatted string.