}
@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
UITreeNode node = (UITreeNode) component;
AbstractUITree tree = ComponentUtils.findAncestor(node, AbstractUITree.class);
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
boolean folder = node.isFolder();
int level = node.getLevel();
String id = node.getClientId(facesContext);
boolean expanded = node.isExpanded();
if (level > 0) { // root will not rendered as an option
writer.startElement(HtmlElements.OPTION, null);
// todo: define where to store the selection of a tree, node.getValue() seems not to be a god place.
// writer.writeAttribute(HtmlAttributes.VALUE, node.getValue().toString(), true); // XXX converter?
writer.writeIdAttribute(id);
writer.writeAttribute(HtmlAttributes.SELECTED, expanded);
writer.writeText("(" + level + ") " + getLabel(node));
if (folder) {
writer.writeText(" \u2192");
}
writer.endElement(HtmlElements.OPTION);
}
if (folder) {
boolean siblingMode = "siblingLeafOnly".equals(tree.getAttributes().get(Attributes.SELECTABLE));
ResponseWriterDivider divider = ResponseWriterDivider.getInstance(facesContext, TreeListboxRenderer.DIVIDER);
boolean alreadyExists = divider.activateBranch(facesContext);
writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
if (!alreadyExists) {
writer.startElement(HtmlElements.DIV, null);