Mohamed Uvais M
Mohamed Uvais M

Reputation: 305

Access Treenode using Rowkey

I have the rowkey(say 0_0,0_1,etc) of treenodes, now is there any simple way to get the node with that rowkey or we need to iterate over entire treenode.

the below code doesn't work

private TreeNode getNode(TreeNode node, String key) {
    for(TreeNode child : node.getChildren()){
        if(key.equals(child.getRowKey())) 
            return child;
        return getNode(child,key);
    }
    return null;
}

Upvotes: 2

Views: 813

Answers (1)

Yagami Light
Yagami Light

Reputation: 1796

to make it short as possible it's impossible to get the node with the rowkey because the type of informations that you pass from your JSF page to your been it's a String one that mean it's impossible to retrieve any data from this informations, like you said in your question the only solution that you have is to loop in your tree to search for it.

Upvotes: 1

Related Questions