1 20 package org.enhydra.barracuda.core.comp.renderer.xml; 21 22 import java.util.*; 23 24 import org.apache.log4j.*; 25 import org.w3c.dom.*; 26 import org.w3c.dom.html.*; 27 28 import org.enhydra.barracuda.core.comp.*; 29 import org.enhydra.barracuda.core.comp.renderer.*; 30 import org.enhydra.barracuda.core.util.dom.*; 31 import org.enhydra.barracuda.plankton.*; 32 33 36 public class XMLTemplateRenderer extends XMLComponentRenderer { 37 38 protected static final Logger logger = Logger.getLogger(XMLTemplateRenderer.class.getName()); 39 40 protected TemplateHelper th = null; 41 42 45 public XMLTemplateRenderer() { 46 this(null); 47 } 48 49 52 public XMLTemplateRenderer(TemplateHelper ith) { 53 setTemplateHelper(ith); 54 } 55 56 59 public void setTemplateHelper(TemplateHelper ith) { 60 th = ith; 61 } 62 63 66 public TemplateHelper getTemplateHelper() { 67 if (th==null) th = new TemplateHelper(this); 68 return th; 69 } 70 71 74 public void renderComponent(BComponent comp, View view, ViewContext vc) throws RenderException { 75 if (!(comp instanceof BTemplate)) throw new NoSuitableRendererException("This renderer can only render BTemplate components"); 77 BTemplate btemplate = (BTemplate) comp; 78 Node node = view.getNode(); 79 80 if (!(view instanceof TemplateView)) throw new InvalidViewException ("Component is bound to an unsupported View:"+view); 82 TemplateView tview = (TemplateView) view; 83 84 if (logger.isDebugEnabled()) showNodeInterfaces(view, logger); 86 87 super.renderComponent(comp, view, vc); 89 90 getTemplateHelper().render(btemplate, tview, vc); 92 } 93 94 } | Popular Tags |