473,320 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to get treedata correctly

3
Hi all, i am using apache tomahawk tree2 component and i get the tree item from DB. The code like:
Expand|Select|Wrap|Line Numbers
  1. public TreeNode getTreeData() {
  2.         List list = getMenuList();
  3.         TreeNode treeData = new TreeNodeBase("foo-folder", "Inbox", false);
  4.         Iterator it = list.iterator();
  5.         HashMap menuTable = new HashMap();
  6.         while (it.hasNext()) {
  7.             Eosmenu item = (Eosmenu) it.next();
  8.             String label = item.getMenuLabel();
  9.             boolean isLeaf = item.getIsLeaf() != null
  10.                     && item.getIsLeaf().equalsIgnoreCase("Y");
  11.             int level = item.getMenuLevel();
  12.             String menuId = item.getMenuId();
  13.             String parentsID = item.getParentsId();
  14.             TreeNodeBase node = new TreeNodeBase();
  15.             if(isLeaf){
  16.                 node.setType("document");
  17.             }else{
  18.                 node.setType("bar-folder");
  19.             }
  20.             node.setDescription(label);
  21.             node.setLeaf(isLeaf);
  22.             menuTable.put(menuId, node);
  23.             if (level == 1) {
  24.                 treeData.getChildren().add(node);
  25.             } else {
  26.                 TreeNodeBase pItem = (TreeNodeBase) menuTable.get(parentsID);
  27.                 if (pItem != null)
  28.                     pItem.getChildren().add(node);
  29.             }
  30.         }
  31.         return treeData;
  32.     }
  33.  
This works well only when the items are in the front of their chirdren. How to let it works correctly when the data in the database like :
id------menuid-------menuname------menulevel------parentid
1----------b---------------bb-------------------2------------------a
2----------a---------------aa-------------------1------------------0
Jan 31 '07 #1
0 898

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Richard van Denzel | last post by:
Hi All, I've defined a table (m) with an double field (bedrag) in it and when I execute the next statement: INSERT INTO m (bedrag) VALUES('-7000,00'); the value get stored correctly. ...
11
by: Bore Biko | last post by:
Dear, I have function that transform time from secconds to string formated as dd:hh:mm:ss (days:hours:minutes:seconds), but it doesent work correctly... Here s code compiled with gcc it goes...
1
by: VMI | last post by:
How can I sort a table column correctly when the table has values like "0", "A1", "AA-1", "B21", "3C", 4-32A", "1", "11-1", 2-A", etc... The table will then be loaded to a grid and that's when...
0
by: Peter Styk | last post by:
Hello, i believe i've tried everything before posting here. Can anyone help? In web config i have the following globalization: <globalization requestEncoding="UTF-8" responseEncoding="UTF-8"...
2
by: MarkusPoehler | last post by:
After saving TEXT combined with HTML Tags into a HTM File by ASP.NET using filestream, the HTM Files is not displayed correctly in IE. Umlaute & e.g. € (Euro Sign) are not shown, I get some wrong...
5
by: Cammie Watson | last post by:
We have a web application that incorporates a style sheet, in our local environment (our desktops) the styles are applied correctly. We think. However when we deploy the application to a server,...
1
by: blueday61 | last post by:
I am a website newbie, and built my site using a template and NVU. After I have it operational, I see that it doesn't display correctly in IE. My site is www.indianacemeteries.org . What do I need...
12
by: filia&sofia | last post by:
For example I would like to dynamically allocate memory for linked list (or complex struct etc.) that has not maximum number of elements. All that I can remember is that I have to have allocated...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.