Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1662
  • Last Modified:

Collapsible Tree Representation of an XML in jSP

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
applekanna
Asked:
applekanna
  • 4
  • 4
  • 3
2 Solutions
 
sudhakar_koundinyaCommented:
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
 
durgaprasad_jCommented:
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
 
applekannaAuthor Commented:
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
Industry Leaders: 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!

 
sudhakar_koundinyaCommented:
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
 
durgaprasad_jCommented:
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
 
durgaprasad_jCommented:
sudhakar , have you tested that . I tested your method and its not working on both Internet explorer and firefox. Check that.
0
 
sudhakar_koundinyaCommented:
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
 
durgaprasad_jCommented:
0
 
applekannaAuthor Commented:
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
 
applekannaAuthor Commented:
Hi Durgaprasad.
Shall try ur link and update as well
Thx
0
 
applekannaAuthor Commented:
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now