richface tree with selectitem (checkbox)

我的未来我决定 提交于 2019-12-08 07:16:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!