问题
I am trying to put checkbox in tree node. My code is as below. I used richfaces - SC.
In JSP page :
<h:panelGrid>
<sc:tree value="#{templateCategoriesBackingBean.rootNode}">
</sc:tree>
</h:panelGrid>
In BackingBean :
private TreeNode<SelectItem> rootNode;
public TreeNode<SelectItem> getRootNode() {
rootNode = new TreeNodeImpl<SelectItem>();
for (int i = 0; i < 10; i++) {
TreeNodeImpl<SelectItem> treeNodeImpl = new TreeNodeImpl<SelectItem>();
treeNodeImpl.setData(new SelectItem(i, "Hello : "+i));
rootNode.addChild(new Integer(i), treeNodeImpl);
}
return rootNode;
}
It shows nodes on screen but like below...
How do I get actual checkbox?
UPDATE
I tried what is being suggested. but that's not what I want.
It definitely returns me a string and I can see label of my SelectItem
in tree.
But what I want is like see example. This is a primefaces tree checkbox example. I want a similar using richfaces or myfaces.
回答1:
Implement a method toString()
for SelectItem
.
Somthing like
class SelectItem {
private String name;
@Override
public String toString(){
return name;
}
}
来源:https://stackoverflow.com/questions/12585285/richface-tree-with-selectitem-checkbox