String clientId = tree.getClientId(context);
boolean dynamic = tree.isDynamic();
String selectionMode = tree.getSelectionMode();
String widget = tree.getOrientation().equals("vertical") ? "VerticalTree" : "HorizontalTree";
WidgetBuilder wb = getWidgetBuilder(context);
wb.initWithDomReady(widget, tree.resolveWidgetVar(), clientId);
wb.attr("dynamic", dynamic)
.attr("highlight", tree.isHighlight(), true)
.attr("animate", tree.isAnimate(), false)
.attr("droppable", tree.isDroppable(), false)
.attr("cache", tree.isCache() && dynamic)
.attr("dragdropScope", tree.getDragdropScope(), null)
.callback("onNodeClick", "function(node, event)", tree.getOnNodeClick());
//selection
if(selectionMode != null) {
wb.attr("selectionMode", selectionMode);
wb.attr("propagateUp", tree.isPropagateSelectionUp());
wb.attr("propagateDown", tree.isPropagateSelectionDown());
}
if(tree.isDraggable()) {
wb.attr("draggable", true)
.attr("dragMode", tree.getDragMode())
.attr("dropRestrict", tree.getDropRestrict());
}
encodeIconStates(context, tree, wb);
encodeClientBehaviors(context, tree);
wb.finish();
}