1 package org.appfuse.webapp.tapestry; 2 3 import org.apache.tapestry.IMarkupWriter; 4 import org.apache.tapestry.IRequestCycle; 5 import org.apache.tapestry.contrib.form.IMultiplePropertySelectionRenderer; 6 import org.apache.tapestry.contrib.form.MultiplePropertySelection; 7 import org.apache.tapestry.form.IPropertySelectionModel; 8 9 17 public class CheckBoxMultiplePropertySelectionRenderer 18 implements IMultiplePropertySelectionRenderer { 19 23 public void beginRender(MultiplePropertySelection component, 24 IMarkupWriter writer, IRequestCycle cycle) { 25 } 26 27 31 public void endRender(MultiplePropertySelection component, 32 IMarkupWriter writer, IRequestCycle cycle) { 33 } 34 35 public void renderOption(MultiplePropertySelection component, 36 IMarkupWriter writer, IRequestCycle cycle, 37 IPropertySelectionModel model, Object option, 38 int index, boolean selected) { 39 writer.begin("input"); 40 writer.attribute("type", "checkbox"); 41 writer.attribute("name", component.getName()); 42 43 String id = component.getName() + "." + model.getValue(index); 44 writer.attribute("id", id); 45 writer.attribute("value", model.getValue(index)); 46 47 if (component.isDisabled()) { 48 writer.attribute("disabled", "disabled"); 49 } 50 51 if (selected) { 52 writer.attribute("checked", "checked"); 53 } 54 55 writer.end(); 56 57 writer.println(); 58 59 writer.begin("label"); 61 writer.attribute("for", id); 62 writer.print(model.getLabel(index)); 63 writer.end(); 65 67 writer.println(); 68 } 69 } 70 | Popular Tags |