1 15 package org.apache.tapestry.form; 16 17 import org.apache.tapestry.IMarkupWriter; 18 import org.apache.tapestry.IRequestCycle; 19 20 27 28 public class RadioPropertySelectionRenderer implements IPropertySelectionRenderer 29 { 30 31 35 36 public void beginRender(PropertySelection component, IMarkupWriter writer, IRequestCycle cycle) 37 { 38 writer.begin("table"); 39 writer.attribute("border", 0); 40 writer.attribute("cellpadding", 0); 41 writer.attribute("cellspacing", 2); 42 } 43 44 48 49 public void endRender(PropertySelection component, IMarkupWriter writer, IRequestCycle cycle) 50 { 51 writer.end(); } 53 54 59 60 public void renderOption( 61 PropertySelection component, 62 IMarkupWriter writer, 63 IRequestCycle cycle, 64 IPropertySelectionModel model, 65 Object option, 66 int index, 67 boolean selected) 68 { 69 writer.begin("tr"); 70 writer.begin("td"); 71 72 writer.beginEmpty("input"); 73 writer.attribute("type", "radio"); 74 writer.attribute("name", component.getName()); 75 writer.attribute("value", model.getValue(index)); 76 77 if (component.isDisabled()) 78 writer.attribute("disabled", "disabled"); 79 80 if (selected) 81 writer.attribute("checked", "checked"); 82 83 writer.end(); 85 writer.println(); 86 87 writer.begin("td"); 88 writer.print(model.getLabel(index)); 89 writer.end(); writer.end(); 92 writer.println(); 93 } 94 } | Popular Tags |