1 15 package org.apache.tapestry.form; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.tapestry.AbstractComponent; 19 import org.apache.tapestry.IMarkupWriter; 20 import org.apache.tapestry.IRequestCycle; 21 import org.apache.tapestry.Tapestry; 22 23 38 39 public abstract class Radio extends AbstractComponent 40 { 41 47 48 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) 49 { 50 51 RadioGroup group = RadioGroup.get(cycle); 52 if (group == null) 53 throw new ApplicationRuntimeException( 54 Tapestry.getMessage("Radio.must-be-contained-by-group"), 55 this, 56 null, 57 null); 58 59 61 boolean rewinding = group.isRewinding(); 62 63 int option = group.getNextOptionId(); 64 65 if (rewinding) 66 { 67 71 if (!isDisabled() && !group.isDisabled() && group.isSelected(option)) 72 group.updateSelection(getValue()); 73 return; 74 } 75 76 writer.beginEmpty("input"); 77 78 writer.attribute("type", "radio"); 79 80 writer.attribute("name", group.getName()); 81 82 85 if (group.isSelection(getValue())) 86 writer.attribute("checked", "checked"); 87 88 if (isDisabled() || group.isDisabled()) 89 writer.attribute("disabled", "disabled"); 90 91 95 writer.attribute("value", option); 96 97 renderInformalParameters(writer, cycle); 98 99 } 100 101 public abstract boolean isDisabled(); 102 103 public abstract Object getValue(); 104 } | Popular Tags |