1 15 package org.apache.tapestry.form; 16 17 import org.apache.tapestry.IMarkupWriter; 18 import org.apache.tapestry.IRequestCycle; 19 20 27 public abstract class Checkbox extends AbstractFormComponent 28 { 29 33 protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle) 34 { 35 writer.beginEmpty("input"); 36 writer.attribute("type", "checkbox"); 37 38 writer.attribute("name", getName()); 39 40 if (isDisabled()) 41 writer.attribute("disabled", "disabled"); 42 43 if (isSelected()) 44 writer.attribute("checked", "checked"); 45 46 renderIdAttribute(writer, cycle); 47 48 renderInformalParameters(writer, cycle); 49 50 writer.closeTag(); 51 } 52 53 58 protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle) 59 { 60 String value = cycle.getParameter(getName()); 61 62 setSelected(value != null); 63 } 64 65 66 public abstract boolean isSelected(); 67 68 69 public abstract void setSelected(boolean selected); 70 } | Popular Tags |