1 20 package org.enhydra.barracuda.core.comp.renderer.html; 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 HTMLTemplateRenderer extends HTMLComponentRenderer { 37 38 protected static final Logger logger = Logger.getLogger(HTMLTemplateRenderer.class.getName()); 39 40 protected EnabledHelper eh = new EnabledHelper(); 41 42 protected TemplateHelper th = null; 43 44 47 public HTMLTemplateRenderer() { 48 this(null); 49 } 50 51 54 public HTMLTemplateRenderer(TemplateHelper ith) { 55 setTemplateHelper(ith); 56 } 57 58 61 public void setTemplateHelper(TemplateHelper ith) { 62 th = ith; 63 } 64 65 68 public TemplateHelper getTemplateHelper() { 69 if (th==null) th = new TemplateHelper(this); 70 return th; 71 } 72 73 86 public Node createDefaultNode(Document doc, BComponent comp, ViewContext vc) throws UnsupportedFormatException { throw new UnsupportedFormatException("Cannot create default node"); 89 } 90 91 94 public void renderComponent(BComponent comp, View view, ViewContext vc) throws RenderException { 95 if (!(comp instanceof BTemplate)) throw new NoSuitableRendererException("This renderer can only render BTemplate components"); 97 BTemplate btemplate = (BTemplate) comp; 98 Node node = view.getNode(); 99 100 if (!(view instanceof TemplateView)) throw new InvalidViewException ("Component is bound to an unsupported View:"+view); 102 TemplateView tview = (TemplateView) view; 103 104 if (logger.isDebugEnabled()) showNodeInterfaces(view, logger); 106 107 super.renderComponent(comp, view, vc); 109 110 getTemplateHelper().render(btemplate, tview, vc); 112 113 eh.setEnabled(node, comp.isEnabled()); 115 } 116 117 } | Popular Tags |