Richfaces Tree Binding 不能正常展开
我在页面用Tree Binding 生成树,但树不以展开..
页面代码如下:
<f:view>
<h:form id="forms">
<rich:tree id="trees" binding="#{treeAccess.tree}" nodeSelectListener="#{node.treeaAction}"></rich:tree>
</h:form>
</f:view>
类代码如下:
public HtmlTree getTree() throws IOException
{
if (tree == null){
tree = new HtmlTree();
tree.setSwitchType(UITree.SWITCH_AJAX);
tree.setStyle("width:300px");
this.bindExpression(tree, "value", "#{node.data}", TreeNode.class);
tree.setVar("item");
this.bindExpression(tree, "nodeFace", "#{item.type}", String.class);
List<UIComponent> lstChild = tree.getChildren();
lstChild.add(this.addTreeNode("Dept", "/images/bureau.gif", "/images/bureau.gif", "#{item.name}", null));
lstChild.add(this.addTreeNode("Ec", "/images/user.gif", "/images/user.gif", "#{item.name}", null));
lstChild.add(this.addTreeNode("Termi", "/images/termi.gif", "/images/termi.gif", "#{item.name}", null));
lstChild.add(this.addTreeNode("Mp", "/images/mp.gif", "/images/mp.gif", "#{item.name}", null));
}
return tree;
}
public void setTree(HtmlTree tree)
{
this.tree = tree;
}
private HtmlTreeNode addTreeNode(String type, String iconLeaf, String icon,
String expression, String function)
{
HtmlTreeNode tnode = new HtmlTreeNode();
tnode.setType(type);
tnode.setIconLeaf(iconLeaf);
tnode.setIcon(icon);
tnode.setOnselected("show('"+type+"');");
HtmlOutputText out = new HtmlOutputText();
this.bindExpression(out, "value", expression, String.class);
tnode.getChildren().add(out);
return tnode;
}
private void bindExpression(UIComponent comp, String type, String expression,
Class classes)
{
ValueExpression bind = app.getExpressionFactory().createValueExpression(ctx.getELContext(), expression, classes);
comp.setValueExpression(type, bind);
}
//数据类
public class Node extends AbstractNode implements TreeNode
{
public Node()
{
super("tree");
this.initDept();
}
private void initDept()
{
//
for (int i = 0; i < 5; i++)
{
DeptNode node = new DeptNode();
node.setId(i + "");
node.setName("Dept_" + i);
this.addChild(node.getId(), node);
for (int j = 0; j < 10; j++)
{
EcNode enode = new EcNode();
enode.setId(j + "e");
enode.setName("Ec_" + j);
node.addChild(enode.getId(), enode);
for (int k = 0; k < 10; k++)
{
TermiNode tnode = new TermiNode();
tnode.setId(j + "_" + k);
tnode.setName("Termi_" + j + "_" + k);
enode.addChild(tnode.getId(), tnode);
for (int z = 0; z < 50; z++)
{
MpNode mnode = new MpNode();
mnode.setId(j + "_" + k + "_" + z);
mnode.setName("Mp_" + j + "_" + k + "_" + z);
tnode.addChild(mnode.getId(), mnode);
}
}
}
}
}
}