This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes TreeView in JSP ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "TreeView in JSP ?" Watch "TreeView in JSP ?" New topic
Author

TreeView in JSP ?

vijay mahendra
Ranch Hand

Joined: Jan 01, 2007
Posts: 51
Hi

I need to display dynamic data as tree view using JSP page.
Is there any tags in jsp to display treeview or anyother choice.

Data should access from Database dynamically not static data

if any please help me in this.

thank you all.
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
If you are familiar with javascript objects, you can create a tree kind structure using javascripts and you can display on the screen, this is advance option if you want the tree leaves to be expanded and some action needs to happen.check this URL(http://www.destroydrop.com/javascripts/tree/ )

Else If you just want to display the tree without providing and action to the tree you can use something like this.

The table would have a structure similar to the following:


col 1col 2col 3col 4
col 1.0   
 buttoncol 2.0  
  buttoncol 3.0 
   buttoncol 4.0
col 1.1   
 buttoncol 2.1  
    
col 1.2   
 buttoncol 2.2  
 button col 3.2 

A reasonably simple Map based data structute should be sufficient to help stored the data model while the table is generated. When generating the HTML, if you turn off all the cell borders then you'll have something that looks much like a tree. If you add little buttons to the cells as indicated by 'button' and write some code behind them then you can use them to collapse/expand individual nodes in the tree. This collapsing/expanding could be done client side (using JavaScritpt and DIV elements wrapping the cells to hide/display) or server side (re-generate the table for that request with certain rows included/excluded).


SCJP 1.2
 
 
subject: TreeView in JSP ?