/** * Author : Daniel Bergström, daniel.bergstrom@home.se * Date: 2002-06-01 * Subject: Modifications to treemenu to enable the tree to be created a little at a time * (or node by node) */ This is a short description of how I used the tree menu, or actually created the tree menu in a different way. I do not claim this description to be complete, or that it explains anything, but i've tried to describe the essential parts. All material should be considered 'as is'. I you have any questions, feel free to e-mail me. /Daniel /** * Requirements */ - Morten's JavaScript Tree Menu, (version 2.3.2 used here) can be found at : http://www.treemenu.org/ - An own developed server side include cgi/servlet/whatever.. that feeds the code frame with suitable code, This is the tricky part where all the work is. It is however necessary when using this menu in large complex systems. Will I share this also? The simple answer is that I guess that you cannot take mauch or any advantages of my own C++ cgi solution, so I will not share any code from there with you. An answer maybe a bit closer to the truth, is that the cgi contains corporate secrets in interfaces aso. I don't think this will render you to much of a problem, if you are not familiar with web techniques you are probably not even reading this... Examples of a typical response that creates and feeds the menu are included below (3,4,5). /** * Procedure and description of modifications */ When familiar with the behaviour of the javascript tree menu, apply following changes to the tree menu: - Store the tree source (mtmcode.js) directly in the frameset (1) - Apply modifications to the tree menu code (2) - Develop a dynamic tree menu data generator as mentioned above. When I was about to use this tree menu, I suddenly found myself facing a problem. The data that was to be presented in the menu were obtained from an existing system by using COM to access the data. The existing behaviour of the interface was to only give the client the data that was on a specified level (If the data in the rootnode was requested, only the root:s subobjects were returned and so on) Allthough it would have been possible to recursively generate the entire tree at a time, that would not have been wise in this case (We are talking about a menu tree with roughly about 1000 nodes) In this case it is much better to modify the tree behaviour itself so that the menu is populated on demand only. With this approach, a regular user that only uses 5% of the menu items, only takes 10% server time, and saves 90% information download. The key to this modification is that the tree is used as a plain navigator, where all menus are only used as a container for other menu items. The only items used to display information is the leaf nodes. By using the tree menu:s features we are able to temporarily add a link also to a menu. Upon node clicking, this link feeds the tree menu with underlying data and is then removed, leaving that menu item initialized. /** * 1: Frameset changes */ tree /** * 2: Tree menu code changes * * Add following lines to the mtmcode.js */ var menu; // the menu object var MTMIconList; // icon list storage var nodeId; // storage for all sub menus In order to prevent the javascript from retriveing already exising node information from the server upon node reclick following is required: Modify the MTMSubAction function by adding the line SubItem.url = ""; below function MTMSubAction(SubItem) { SubItem.expanded = (SubItem.expanded) ? false : true; if(SubItem.expanded) { MTMExpansion = true; } MTMClickedItem = SubItem; if(MTMTrackedItem && MTMTrackedItem != SubItem.number) { MTMTrackedItem = false; } if(MTMEmulateWE || SubItem.url == "" || !SubItem.expanded) { setTimeout("MTMDisplayMenu()", 10); return false; } else { if(SubItem.target == "_blank" || !MTMUA.resolveURL(SubItem.url, true) || (SubItem.target.indexOf("_") != 0 && MTMTrackTarget(SubItem.target) == false)) { setTimeout("MTMDisplayMenu()", 10); } SubItem.url = ""; // db 20020531 this is a fix to block multiple calls to cgi from menus return true; } } /** * 3. Initial simplified reponse from server side include cgi * * Here the target for the menus A and B is a call to the server side include tree.cgi * The target frame is set to code, since we want the cgi response to be added to the tree menu. * Note that all script elements are refered to as 'parent.' * (Which means that it is stored in the frameset) * All links added th items that are menus will later be disabled (Here A and B links will be removed * after that they has been clicked). */ /** * 4. Menu item A clicked, update response from server * * The sub item AA in menu A is also a menu, same behaviour as above. */ /** * 5. Menu item AA clicked, update response from server * * Menu item AA contain only leaf nodes, response will here be the default frame, which is 'text' * On mode createList the cgi generates a response completely different from that used to feed the tree menu */