org.barracudamvc.core.comp.renderer
Class DOMComponentRenderer

java.lang.Object
  extended byorg.barracudamvc.core.comp.renderer.DOMComponentRenderer
All Implemented Interfaces:
Renderer
Direct Known Subclasses:
HTMLComponentRenderer, HTMLScriptRenderer, HTMLScriptResourceRenderer, XMLComponentRenderer

public abstract class DOMComponentRenderer
extends Object
implements Renderer

This interface defines the methods needed to implement a Renderer.


Field Summary
protected static org.apache.log4j.Logger logger
           
 
Constructor Summary
DOMComponentRenderer()
           
 
Method Summary
 Node addChildToParent(Node parent, Node child)
          The purpose of this method is to add a child to a parent.
 Node createDefaultNode(Document doc, BComponent comp, ViewContext vc)
          The purpose of this method is for a renderer to provide a default node (if none exists).
 void renderComponent(BComponent comp, View view, ViewContext vc)
          This method should actually render the data from the component into the view, taking into consideration the specified ViewContext.
 void showNodeInterfaces(Object object, org.apache.log4j.Logger extLogger)
          This is just a debugging method to make it easy to show the interfaces of the object being rendered with special treatment for View and BComponent objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger
Constructor Detail

DOMComponentRenderer

public DOMComponentRenderer()
Method Detail

createDefaultNode

public Node createDefaultNode(Document doc,
                              BComponent comp,
                              ViewContext vc)
                       throws UnsupportedFormatException
The purpose of this method is for a renderer to provide a default node (if none exists). This is essentially where you would say "if I need to render myself, and I'm not actually bound to anything, what should the default markup look like if I had to create it." In most cases, its perfectly fine to just throw an UnsupportedFormatException (indicating that there is no default). The only renderer that currently implements this method is the HTMLLinkRenderer.

Specified by:
createDefaultNode in interface Renderer
Parameters:
doc - the master Document which can be used to create elements from scratch
comp - the component that we're dealing with for the current request
vc - the view context for the current request
Returns:
a default node (created from scratch)
Throws:
UnsupportedFormatException - if the renderer has no default node

addChildToParent

public Node addChildToParent(Node parent,
                             Node child)
                      throws InvalidNodeException
The purpose of this method is to add a child to a parent. In many cases, this method is used to ensure that the resulting markup is valid, by inserting the appropriate markup in between the child and the parent. In many cases, the generic Component renderer will be the only renderer that actually implements this method.

Specified by:
addChildToParent in interface Renderer
Parameters:
parent - the parent Node
child - the child Node
Returns:
the resulting parent node
Throws:
InvalidNodeException - if teh child cannot be added to the parent

renderComponent

public void renderComponent(BComponent comp,
                            View view,
                            ViewContext vc)
                     throws RenderException
This method should actually render the data from the component into the view, taking into consideration the specified ViewContext. Generally, every renderer will implement this method.

Specified by:
renderComponent in interface Renderer
Parameters:
comp - the component to be rendered
view - the view the component should be rendered in
vc - the view context
Throws:
RenderException - if unable to render the component in the specified view

showNodeInterfaces

public void showNodeInterfaces(Object object,
                               org.apache.log4j.Logger extLogger)
This is just a debugging method to make it easy to show the interfaces of the object being rendered with special treatment for View and BComponent objects. Generally, there is no need to re-implement this method.

Note: if debugging is not enabled for the external logger, this method will return immediately without doing any extra work. As such, this method can be called directly without manually checking whether debugging is enabled.



Copyright © 2004 BarracudaMVC.org All Rights Reserved.