if (walker.next()) { if(!tree.getNode().isLeaf()){ out.startElement(HTML.UL_ELEM, tree); out.writeAttribute(HTML.ID_ATTR,"page_tree_div",null); out.writeAttribute(HTML.CLASS_ATTR,"tree_drag_drop",null); }
    public void encodeChildren(FacesContext context, UIComponent component) throws IOException{    	//    	component.restoreState(context, component);    	//    	HtmlTree tree = (HtmlTree)component;    	IWTree tree = (IWTree)component;    	    	tree.setShowLines(false);       	if (!component.isRendered())    		return;    	if (tree.getValue() == null)     		return;    	ResponseWriter out = context.getResponseWriter();    	String clientId = null;    	if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)){    		clientId = component.getClientId(context);    	}    	boolean isOuterSpanUsed = false;    	if (clientId != null){    		isOuterSpanUsed = true;    		out.startElement("span", component);//    		out.writeAttribute("id", clientId, "id");    		    		out.writeAttribute("id", component.getId(), "id");    		out.startElement("div", component);out.writeAttribute("id", "div_id_"+component.getId(), "id");    		    	}    	boolean clientSideToggle = tree.isClientSideToggle();    	boolean showRootNode = tree.isShowRootNode();    	TreeState state = tree.getDataModel().getTreeState();    	TreeWalker walker = tree.getDataModel().getTreeWalker();        	walker.reset();    	walker.setTree(tree);    	walker.setCheckState(!clientSideToggle); // walk all nodes in client mode    	out.startElement(HTML.UL_ELEM, tree);            	out.writeAttribute(HTML.ID_ATTR,"page_tree_div",null);    	out.writeAttribute(HTML.CLASS_ATTR,"tree_drag_drop",null);        	if (showRootNode) {        // encode the tree (starting with the root node)     		if (walker.next()) {    			encodeRoot(context, out, tree, walker);    		}            	}    	else {    		    		TreeNode rootNode = tree.getNode();    		String rootNodeId = tree.getNodeId();    		if(!state.isNodeExpanded(rootNodeId)){    			state.toggleExpanded(rootNodeId);    		}        // now encode each of the nodes in the level immediately below the root    		for (int i=0; i < rootNode.getChildCount(); i++) {    			if (walker.next()){      				encodeRoot(context, out, tree, walker);    			}    		}    	}        	out.endElement(HTML.UL_ELEM);    	// reset the current node id once we're done encoding everything    	tree.setNodeId(null);    	if (isOuterSpanUsed) {    		out.endElement("div");    		out.endElement("span");    	}    }