public void encodeEnd(FacesContext facesContext, UIComponent component)
throws IOException {
int level = ((UITreeListboxBox) component).getLevel();
UITreeListbox tree = (UITreeListbox) component.getParent();
List<UITreeOldNode> selectionPath = tree.getSelectionPath();
String className = "tobago-treeListbox-default";
if (selectionPath.size() > 0 && selectionPath.size() - 1 <= level
&& selectionPath.get(selectionPath.size() - 1).getTreeNode().isLeaf()) {
className += " tobago-treeListbox-unused";
}
String treeId = tree.getClientId(facesContext);
TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();
final boolean siblingMode
= "siblingLeafOnly".equals(tree.getAttributes().get(ATTR_SELECTABLE));
String listboxId = treeId + SUBCOMPONENT_SEP + "cont_" + level;
String onChange = "tbgTreeListboxChange(this, '" + treeId + "')";
String onClick = "tbgTreeListboxClick(this, '" + treeId + "')";
writer.startElement(HtmlConstants.SELECT, component);
writer.writeIdAttribute(listboxId);
writer.writeClassAttribute(className);
writer.writeAttribute(HtmlAttributes.STYLE , null, ATTR_STYLE);
writer.writeAttribute(HtmlAttributes.SIZE, "2", null);
if (siblingMode) {
writer.writeAttribute(HtmlAttributes.ONCHANGE, onChange, null);
} else {
writer.writeAttribute(HtmlAttributes.ONCLICK, onClick, null);
}
writer.writeAttribute(HtmlAttributes.MULTIPLE, siblingMode);
List nodes = ((UITreeListboxBox) component).getNodes();
for (int i = 0; i < nodes.size(); i++) {
UITreeOldNode treeNode = (UITreeOldNode) nodes.get(i);
DefaultMutableTreeNode node = treeNode.getTreeNode();
writer.startElement(HtmlConstants.OPTION, treeNode);
// writer.writeAttribute(HtmlAttributes.ONCLICK, "tbgTreeListboxClick(this, '" + treeId + "')", null);
writer.writeAttribute(HtmlAttributes.VALUE, Integer.toString(i), null);
if (treeNode.equals(tree.getSelectedNode(level))
|| tree.isSelectedNode(node)) {
writer.writeAttribute(HtmlAttributes.SELECTED, true);
}
writer.writeAttribute(HtmlAttributes.TITLE, null, ATTR_TIP);
writer.writeText(treeNode.getAttributes().get(ATTR_NAME), null);
if (node.getChildCount() > 0) {