com.taursys.xml.render
Class TemplateRenderer

java.lang.Object
  extended bycom.taursys.xml.render.AbstractRenderer
      extended bycom.taursys.xml.render.VisibleRenderer
          extended bycom.taursys.xml.render.DocumentElementRenderer
              extended bycom.taursys.xml.render.TemplateRenderer

public class TemplateRenderer
extends DocumentElementRenderer

TemplateRenderer is a subcomponent which renders a Template by replication.

Version:
1.0
Author:
Marty Phelan

Field Summary
 
Fields inherited from class com.taursys.xml.render.AbstractRenderer
id, parentDocumentAdapter
 
Constructor Summary
TemplateRenderer(Template template)
          Constructs a new TemplateRenderer
 
Method Summary
protected  void alterIDs(org.w3c.dom.Element parent, java.lang.String appendValue)
          Alter ID's for this node and its children recursively to avoid duplicates.
protected  void cloneSelf(java.lang.String appendValue)
          Populate children of this node and create a clone of this node.
 java.util.Collection getClones()
          Get the collection of cloned nodes which were generated by the render method.
 void recycle()
          Recycles this component by restoring the Document element to a default state.
protected  void removeClones()
          Remove all clones from parentNode and clear clones Collection.
 void render()
          Renders the Template and its children to the Document.
 
Methods inherited from class com.taursys.xml.render.DocumentElementRenderer
renderContents
 
Methods inherited from class com.taursys.xml.render.AbstractRenderer
getComponent, getComponentNode, getDocument, getParentNode, getSiblingNode, init, isRemoved, removeSelf, restoreSelf, setRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateRenderer

public TemplateRenderer(Template template)
Constructs a new TemplateRenderer

Method Detail

recycle

public void recycle()
             throws RecycleException
Recycles this component by restoring the Document element to a default state. This implementation simply makes it visible, and dispatches a recycle event to any children.

If a Document element was left invisible, and the Document changed, then the invisible component would become dereferenced.

Overrides:
recycle in class DocumentElementRenderer
Throws:
RecycleException - if problem occurs during recycling.

render

public void render()
            throws RenderException
Renders the Template and its children to the Document. This subcomponent uses replication as its rendering strategy. It begins by removing any cloned node from the Document (from prior use). If the Template isVisible, it begins by restoring itself back into the Document (if removed by prior use) and then iterates over the items in the collectionValue holder. For each item, it invokes the Template's renderDispatcher so child components will render their values. It then clones itself, and alters the ID's in the cloned branch by appending a row number to the ID (example "__row3"). Finally, it removes itself from the document.

Overrides:
render in class AbstractRenderer
Throws:
RenderException - if any problem occurs during rendering

removeClones

protected void removeClones()
Remove all clones from parentNode and clear clones Collection.


cloneSelf

protected void cloneSelf(java.lang.String appendValue)
Populate children of this node and create a clone of this node. Also invokes alterIDs with given appendValue to avoid duplicate ID's (violation of XML specification).

Parameters:
appendValue - to append to ID's to avoid duplicates during cloning

alterIDs

protected void alterIDs(org.w3c.dom.Element parent,
                        java.lang.String appendValue)
Alter ID's for this node and its children recursively to avoid duplicates.


getClones

public java.util.Collection getClones()
Get the collection of cloned nodes which were generated by the render method.

Returns:
the collection of cloned nodes which were generated by the render method.


Copyright © 2007 Martin T Phelan. All Rights Reserved.