开发者

rich:tree - programmatically set the selected node

I have a tree (a parent could have any number of child ) and an inputText 开发者_如何学Pythonfor searching nodes by name. Assume the following tree:

A
--A1
----AA1
--A2

Where A has two children A1 and A2, A1 has one child AA1. When i type A1 in input text , i want to set nodes (A1,AA1) programmatically to select and if it is necessary expands nodes.

(i have a list<T> for building my tree)


I'm not sure what exactly you're asking for but I'll assume you want to set the value of node A1 and all it's children when you type "A1".

First you need to check that the user input is formatted correctly (doesn't look like A?1 when only letters and numbers are used to identify nodes). Second, you need to locate the indicated node. Third, you need to set the value and check for children. Finally, once children are discovered, go back to the third step for each child.

Recursion could make your method more sleek but would not be necessary if you don't like recursion.

Sorry for such a vague answer but without a more detailed question it's hard to give a more detailed solution.


You can use TreeNode of richfaces instead of list, so you can easily achieve your requirements. because using it you can easily get parent-child relationship using key value

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜