public class TreeChildrenRenderer extends XULRenderer {
public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
TreeComponent treeComponent = (TreeComponent) component.getParent();
TreeChildrenComponent treeChildrenComponent = (TreeChildrenComponent) component;
ResponseWriter responseWriter = facesContext.getResponseWriter();
TreeModel treeModel = treeComponent.getTreeModel();
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treeModel.getRoot();
if (treeNode != null) {
String var = (String) component.getParent().getAttributes().get("var");
if (var != null) {
Map sessionMap = facesContext.getExternalContext().getSessionMap();
synchronized (sessionMap) {
responseWriter.startElement("treechildren",component);
treeChildrenComponent.setNodeId(component.getClientId(facesContext));
responseWriter.writeAttribute("id",treeChildrenComponent.getNodeId(), "id");
renderAttributes(facesContext,component,(List) component.getAttributes().get("annotatedAttributes"));
for (int i = 0; i < treeNode.getChildCount(); i++) {
encodeTreeNode(facesContext, component, (DefaultMutableTreeNode) treeNode.getChildAt(i), i,"" + i );
}
responseWriter.endElement("treechildren");