This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Store Data in Tree Node Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Store Data in Tree Node" Watch "Store Data in Tree Node" New topic
Author

Store Data in Tree Node

paresh doshi
Ranch Hand

Joined: Nov 20, 2006
Posts: 81
Hi,

I am using struts framework in my project... I get the result set from database. I want to store it in a tree like data structure.. I want to set the parent and child nodes.. Is there any api available in struts that allow me to save the data in form of tree structure...

Please help...


Thanks.<br />Paresh Doshi<br />SCJP 1.4
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
As I see it, the best option would be to create your own custom classes that map to the tree-structured model you are trying to create. For example, if you are modeling a company's chain-of-command organizational chart, you could create the following class:

Using a custom class like this to populate a tree structure is generally much better than using some generic tree/node classes because it's easier to read and understand what the organization is.

If you then want to display a tree structure, I'd suggest using one of the many JavaScript tree creation frameworks out there, such as treeview. You can then write code that will translate your model into the necessary JavaScript code to create the tree.
[ April 22, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Store Data in Tree Node
 
Similar Threads
Global VS trees
Displaying a tree?
Collection Framework,making my mind a bit unstable
dynamic tree menu using struts tiles framework
how to create a tree structure in jsp