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 HTMLToggleRenderer extends HTMLInputRenderer { 37 38 protected static final Logger logger = Logger.getLogger(HTMLToggleRenderer.class.getName()); 39 40 protected BToggleButton btbcomp = null; 41 42 45 public void renderComponent(BComponent comp, View view, ViewContext vc) throws RenderException { 46 if (!(comp instanceof BToggleButton)) throw new NoSuitableRendererException("This renderer can only render BToggleButton components; comp is of type:"+comp.getClass().getName()); 48 btbcomp = (BToggleButton) comp; 49 Node node = view.getNode(); 50 51 if (logger.isDebugEnabled()) showNodeInterfaces(view, logger); 53 54 super.renderComponent(comp, view, vc); 56 57 if (node instanceof HTMLInputElement) { 59 if (logger.isInfoEnabled()) logger.info("Rendering based on HTMLInputElement interface..."); 60 HTMLInputElement el = (HTMLInputElement) node; 61 62 el.setChecked(btbcomp.isSelected()); 64 65 } else { 66 String errmsg = "Node does not implement HTMLInputElement and cannot be rendered: "+node; 67 logger.warn(errmsg); 68 throw new NoSuitableRendererException(errmsg); 69 } 70 } 71 }
| Popular Tags
|