String id = (String) params.get("id");
int cnt = 1;
//This will interate through all lists
ValueStack stack = this.context.getStack();
if (listObj != null) {
Iterator itt = MakeIterator.convert(listObj);
while (itt.hasNext()) {
Object item = itt.next();
stack.push(item);
//key
Object itemKey = findValue(listKey != null ? listKey : "top");
String itemKeyStr = StringUtils.defaultString(itemKey == null ? null : itemKey.toString());
//value
Object itemValue = findValue(listValue != null ? listValue : "top");
String itemValueStr = StringUtils.defaultString(itemValue == null ? null : itemValue.toString());
//Checkbox button section
Attributes a = new Attributes();
a.add("type", "checkbox")
.add("name", name)
.add("value", itemKeyStr)
.addIfTrue("checked", isChecked(params, itemKeyStr))
.addIfTrue("readonly", params.get("readonly"))
.addIfTrue("disabled", disabled)
.addIfExists("tabindex", params.get("tabindex"))
.addIfExists("id", id + "-" + Integer.toString(cnt));
start("input", a);
end("input");
//Label section
a = new Attributes();
a.add("for",id + "-" + Integer.toString(cnt))
.addIfExists("class", params.get("cssClass"))
.addIfExists("style", params.get("cssStyle"));
super.start("label", a);
if (StringUtils.isNotEmpty(itemValueStr))
characters(itemValueStr);
super.end("label");
//Hidden input section
a = new Attributes();
a.add("type", "hidden")
.add("id", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
.add("name", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
.add("value", "")
.addIfTrue("disabled", disabled);
start("input", a);
end("input");
stack.pop();
cnt++;
}
}
}