BuildCheckboxTagpublic class BuildCheckboxTag extends TagSupport This class is a custom action for creating an HTML checkbox
control, using status information exposed by the JSTL forEach
action. |
Fields Summary |
---|
private String | name | private String[] | selections |
Methods Summary |
---|
public int | doEndTag()
LoopTag parent = (LoopTag) findAncestorWithClass(this, LoopTag.class);
if (parent == null) {
throw new JspTagException("buildCheckbox: invalid parent");
}
Map.Entry current = (Map.Entry) parent.getCurrent();
String text = (String) current.getKey();
String value = (String) current.getValue();
JspWriter out = pageContext.getOut();
StringBuffer checkbox = new StringBuffer("<input type=\"checkbox\"");
checkbox.append(" name=\"").append(name).append("\"").
append(" value=\"").append(value).append("\"");
if (isSelected(value, selections)) {
checkbox.append(" checked");
}
checkbox.append(">").append(text);
try {
out.write(checkbox.toString());
}
catch (IOException e) {}
return EVAL_PAGE;
| private boolean | isSelected(java.lang.String value, java.lang.String[] selections)
return StringFormat.isValidString(value, selections, false);
| public void | setName(java.lang.String name)
this.name = name;
| public void | setSelections(java.lang.String[] selections)
this.selections = selections;
|
|