?
Solved

Collapsible Tree Representation of an XML in jSP

Posted on 2005-02-27
11
Medium Priority
?
1,633 Views
Last Modified: 2012-08-14
Hi,
I have an XML fiile that i  fecth from the database or create  on the fly,
I want to provide  a collapsible tree view of the data in the XML File on the JSP page.

Any help as to how to do it!!!!

Thanks

AK
0
Comment
Question by:applekanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
11 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 300 total points
ID: 13417611
One Idea is creating the tree control using style sheets and JavaScript.
Here is theory with small example (contains 6 pages)
http://www.devx.com/getHelpOn/Article/11874

When I want to display tree control on Web Page I always prefer this model

Regards
Sudhakar
0
 
LVL 6

Assisted Solution

by:durgaprasad_j
durgaprasad_j earned 200 total points
ID: 13417616
hi,
I dont think you need to do this in your JSP.
Now a days, almost all browsers have this support. like [ IE, Firefox, etc. ]

If you want to do this on your own , you have to use <div> html tag.

Hope this helps
0
 
LVL 3

Author Comment

by:applekanna
ID: 13417633
I need to do it on my JSP coz the XML holds the data and xml is only part of the content, I need to provide more details as well.

It will be something lke this. Assume we have data for our phone bill for a year.
I will pull data in an XML and
display
 
Customer Name
   - Janu
   - Feb
   - Mar
        - STD
              1000
        - ISD
              1200
        - Mobile
               2000
   - Apr

Each month shud be expandable and be able to provide more deatils when clicked on it.

>>If you want to do this on your own , you have to use <div> html tag.
i am not sure abt the <div> tag is it using DHTML ?... I did a google and got some DHTML implementaions...but when i run it asks for activex componets that IE blocks so was concerned this wud be an issue with client.

sudhakar,
 I shall try this.

Thx
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 13417638
Or you have to traverse over your XML document using DOM and build the HTML text something like below

Some thing like below as an example. And you need to write collapse and expand functionalities using Java Script
<UL>
      <LI>Main<UL>
            <LI><A HREF="javascript:expand()">Sub Main1</A>
            <LI><A HREF="javascript:expand()">Sub Main2 </A><UL>
                  <LI>Sub Main 2.1
                  
            </UL>
      </UL>

</UL>
0
 
LVL 6

Expert Comment

by:durgaprasad_j
ID: 13417790
hi,
DIV tag is not in DHTML. It is html only. You can simply do this using some simple javascript and div and span tags.
I think the above comment is much easier and better...
0
 
LVL 6

Expert Comment

by:durgaprasad_j
ID: 13417804
sudhakar , have you tested that . I tested your method and its not working on both Internet explorer and firefox. Check that.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 13417823
you mean javascript:expand?? -It won't work :-)

I gave that as an example. AK must write javascript code for expand and collapse functionality  for the tree he generates

:-)
0
 
LVL 6

Expert Comment

by:durgaprasad_j
ID: 13417826
0
 
LVL 3

Author Comment

by:applekanna
ID: 13417942
Hi,

http://www.devx.com/getHelpOn/Article/11874 works fine but need to make some changes to xml and xslt if i want to get it working for my app as my XML will be dynamic. I also need to put the page as a JSP page and see if it still works.

I am trying this now,
http://dataml.net/articles/jsp101/jsptreeview.htm

Shall update  
~AK
0
 
LVL 3

Author Comment

by:applekanna
ID: 13417946
Hi Durgaprasad.
Shall try ur link and update as well
Thx
0
 
LVL 3

Author Comment

by:applekanna
ID: 13418426
http://dataml.net/articles/jsp101/jsptreeview.htm works fine, I am able to make a model and view out of it .

Thx you all
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question