1 15 package org.apache.tapestry.contrib.form; 16 17 import org.apache.tapestry.IMarkupWriter; 18 import org.apache.tapestry.IRequestCycle; 19 import org.apache.tapestry.form.IPropertySelectionModel; 20 21 28 29 public class CheckBoxMultiplePropertySelectionRenderer 30 implements IMultiplePropertySelectionRenderer 31 { 32 33 37 38 public void beginRender( 39 MultiplePropertySelection component, 40 IMarkupWriter writer, 41 IRequestCycle cycle) 42 { 43 writer.begin("table"); 44 writer.attribute("border", 0); 45 writer.attribute("cellpadding", 0); 46 writer.attribute("cellspacing", 2); 47 } 48 49 53 54 public void endRender( 55 MultiplePropertySelection component, 56 IMarkupWriter writer, 57 IRequestCycle cycle) 58 { 59 writer.end(); } 61 62 67 68 public void renderOption( 69 MultiplePropertySelection component, 70 IMarkupWriter writer, 71 IRequestCycle cycle, 72 IPropertySelectionModel model, 73 Object option, 74 int index, 75 boolean selected) 76 { 77 writer.begin("tr"); 78 writer.begin("td"); 79 80 writer.beginEmpty("input"); 81 writer.attribute("type", "checkbox"); 82 writer.attribute("name", component.getName()); 83 writer.attribute("value", model.getValue(index)); 84 85 if (component.isDisabled()) 86 writer.attribute("disabled", "disabled"); 87 88 if (selected) 89 writer.attribute("checked", "checked"); 90 91 writer.end(); 93 writer.println(); 94 95 writer.begin("td"); 96 writer.print(model.getLabel(index)); 97 writer.end(); writer.end(); 100 writer.println(); 101 } 102 } | Popular Tags |