📄 checkboxmultiplepropertyselectionrenderer.java
字号:
package org.appfuse.webapp.tapestry;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.contrib.form.IMultiplePropertySelectionRenderer;
import org.apache.tapestry.contrib.form.MultiplePropertySelection;
import org.apache.tapestry.form.IPropertySelectionModel;
/**
* Implementation of {@link IMultiplePropertySelectionRenderer} that
* produces checkbox (<input type=checkbox>) elements with ids
* on the labels.
*
* @author Matt Raible
*
**/
public class CheckBoxMultiplePropertySelectionRenderer
implements IMultiplePropertySelectionRenderer {
/**
* Writes the <table> element.
*
**/
public void beginRender(MultiplePropertySelection component,
IMarkupWriter writer, IRequestCycle cycle) {
}
/**
* Closes the <table> element.
*
**/
public void endRender(MultiplePropertySelection component,
IMarkupWriter writer, IRequestCycle cycle) {
}
public void renderOption(MultiplePropertySelection component,
IMarkupWriter writer, IRequestCycle cycle,
IPropertySelectionModel model, Object option,
int index, boolean selected) {
writer.begin("input");
writer.attribute("type", "checkbox");
writer.attribute("name", component.getName());
String id = component.getName() + "." + model.getValue(index);
writer.attribute("id", id);
writer.attribute("value", model.getValue(index));
if (component.isDisabled()) {
writer.attribute("disabled", "disabled");
}
if (selected) {
writer.attribute("checked", "checked");
}
writer.end();
writer.println();
//writer.printRaw(" ");
writer.begin("label");
writer.attribute("for", id);
writer.print(model.getLabel(index));
writer.end(); // <label>
//writer.printRaw(" ");
writer.println();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -