1 20 package org.enhydra.barracuda.core.comp.renderer.html; 21 22 import java.util.*; 23 24 import org.w3c.dom.*; 25 import org.w3c.dom.html.*; 26 27 import org.enhydra.barracuda.core.comp.*; 28 import org.enhydra.barracuda.core.comp.renderer.*; 29 30 34 public class EnabledHelper extends DOMComponentRenderer { 35 36 39 public void setEnabled(Node node, boolean enabled) { 40 41 if (node instanceof HTMLAnchorElement) { 43 Element el = (Element) node; 44 if (!enabled) el.removeAttribute("href"); 45 if (!enabled) el.removeAttribute("target"); 46 47 } else if (node instanceof HTMLButtonElement) { 49 ((HTMLButtonElement) node).setDisabled(!enabled); 50 51 } else if (node instanceof HTMLInputElement) { 53 ((HTMLInputElement) node).setDisabled(!enabled); 54 55 } else if (node instanceof HTMLOptGroupElement) { 57 ((HTMLOptGroupElement) node).setDisabled(!enabled); 58 59 } else if (node instanceof HTMLOptionElement) { 61 ((HTMLOptionElement) node).setDisabled(!enabled); 62 63 } else if (node instanceof HTMLSelectElement) { 65 ((HTMLSelectElement) node).setDisabled(!enabled); 66 67 } else if (node instanceof HTMLStyleElement) { 69 ((HTMLStyleElement) node).setDisabled(!enabled); 70 71 } else if (node instanceof HTMLTextAreaElement) { 73 ((HTMLTextAreaElement) node).setDisabled(!enabled); 74 } 75 76 } 77 78 } | Popular Tags |