FacesContext context = FacesContext.getCurrentInstance();
if (value != null) {
ValueBinding valueBinding = context.getApplication()
.createValueBinding(value);
TreeModel treeModel = (TreeModel) (valueBinding.getValue(context));
if (treeModel == null) {
// create default model
treeModel = new DefaultTreeModel();
valueBinding.setValue(context, treeModel);
}
}
int answer = super.doStartTag();
HtmlTree tree = (HtmlTree) getComponentInstance();
if (getCreated() && parseBoolean(expandRoot)) {
// component was created, so expand the root node
TreeModel model = tree.getModel(context);
if (model != null) {
tree.expandPath(new TreePath(new Object[] { model.getRoot() }),
context);
}
}
tree.addToModelListeners();