@Override
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
final UITreeSelect select = (UITreeSelect) component;
final AbstractUITreeNode node = ComponentUtils.findAncestor(select, AbstractUITreeNode.class);
final AbstractUIData data = ComponentUtils.findAncestor(node, AbstractUIData.class);
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
if (data instanceof AbstractUITreeListbox) {
writer.write(StringUtils.defaultString((String) select.getLabel()));
return;
}
final String id = select.getClientId(facesContext);
final String currentValue = getCurrentValue(facesContext, select);
final boolean checked;
if (select.isValueStoredInState()) {
checked = data.getSelectedState().isSelected(node.getPath());
} else {
checked = "true".equals(currentValue);
}
final boolean folder = data.isFolder();
final Selectable selectable = data.getSelectableAsEnum();
writer.startElement(HtmlElements.SPAN, null);
writer.writeClassAttribute(Classes.create(select));
HtmlRendererUtils.writeDataAttributes(facesContext, writer, select);