I wanted to engage a Java web tree from the beginning of the year. Because I need to have such a component, I will use it at any time. I used to use it for a few more time, and the ACCP brother has made a while, and she is finally coming.
How to say this is also the first time I wrote the article on 9cbs. Of course, it's a word, I don't say ^ Q ^
If the ASP seems to have you have to write this thing, Microsoft has prepared this tree early. And I want to write now is a tree.
The first is the definition of the database Tree table:
ID -------> Primary key (int)
p_id -------> Father (int)
Name -------> Name (VARCHAR (16))
SortValue -------> Sort Value (int)
Then the class of two trees: Tree and Node
Tree: Includes some of the methods of adding, deleting, modifying nodes, database records are linear, not sorted into a tree shape, just take all data to take all data to TREE, Tree will Tissue recorded into a tree. Then you get the XML form of the tree by calling the asxml method.
Node: Node class uses synthetic mode to save information about the tree node.
Summary now:
1. Read the data from the database, add it to TREE to manage linear data into a tree.
2. Client (typically JSP) Over-Torge Tree's asxml method gets the tree's XML form and then forms a web tree with XSL style sheets.
The above is the simplest implementation. Look at the example tree you will find that the background of the node name on the right is blue, in fact it is a text box, and finally I want to make it to dynamically add deleted trees on the web.
Hey, temporarily writing here, time is too urgent, write too thick, source code I have not finished, if you need it, then post it. I hope to give you a little bit, please give your younger brother a little suggestion. After doing well, I will put the source code document a piece.