TREES in JSP

how can i create Tree like structure in JSP.can i use swings.IF yes what can be the container.
I am trying to access database and show the data in TREE node like structure.
Rohit

<%@ page import="java.util.*"%>
<jsp:useBean id="TreeBean" class="resourceweb.TreeBean"/>
<html>
<head>
<title>Listing of resources Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE type=text/css>A:visited {
     COLOR: #cc0033
A:link {
     COLOR: #cc0033
A:active {
     COLOR: #cc0033
A:hover {
     COLOR: #ff0033
</STYLE>
<script language="JavaScript">
<!--
var Open = ""
var Closed = ""
function preload(){
if(document.images){
     Open = new Image(16,13)
     Closed = new Image(16,13)
     Open.src = "img/openfolder.gif"
     Closed.src = "img/closedfolder.gif"
function showhide(what,what2){
if (what.style.display =='none'){
what.style.display='';
what2.src=Open.src
else{
what.style.display='none'
what2.src=Closed.src
-->
</SCRIPT>
</head>
<BODY bgColor=white onload=preload()>
<FONT face=Verdana size=2></FONT><FONT face=Verdana size=2>
<%
HttpSession session1 = request.getSession();
Vector v = (Vector)session1.getAttribute("treeResults");
String cat = (String)session1.getAttribute("catid");
String loc = (String)session1.getAttribute("location");
int i = 0;                                                                                     
int catid = 0;
int resid = 0;
resourceweb.TreeBean c = null;
String tempType = null;
GregorianCalendar now = new GregorianCalendar();
int mth = (now.get(Calendar.MONTH)) + 1;
int year = now.get(Calendar.YEAR);
%>
<%
//iterate through beans to display category.
c= (resourceweb.TreeBean)v.elementAt(i);
while (i < v.size())
     tempType = c.getResourceCategory();
     catid++;
     resid++;
     %>
     //this is where the top level stuff are
     <SPAN id=cat1<%=catid%> onclick=showhide(res<%=resid%>,cat<%=catid%>)
     style="CURSOR: hand; FONT-FAMILY: Verdana; FONT-WEIGHT: bold;">
          <FONT
               style="TEXT-DECORATION: none">
               <!-- <IMG id=<%=c.getResourceCategory()%> src="img/closedfolder.gif"> -->
          <IMG id=cat<%=catid%> src="img/closedfolder.gif">
          </FONT>
     <%=c.getResourceCategory()%>
     </SPAN><BR>
     //this is where the second level stuff are.
     <SPAN id=res<%=resid%> style="DISPLAY: none">
     <%
     while((tempType.equals(c.getResourceCategory())) && (i < v.size()))
     %>
     <% if (i == (v.size() - 1)) { %>
          <IMG src="img/lastnode.gif">
          <% }
          else
          {%>
          <IMG src="img/node.gif">
          <% } %>
          <IMG src="img/doc.gif">
          <a href="../servlet/resourceweb.MthViewDispatcherServlet?Action=MthView&ResId=<%=c.getResourceId()%>&Mth=<%=mth%>&Year=<%=year%>&CatId=<%=cat%>&Location=<%=loc%>&View=Tree target=folderFrame"><%=c.getResourceName()%></a>
          <BR>
     <%
     ++i;
          if(i < v.size())
          c= (resourceweb.TreeBean)v.elementAt(i);
     }      %>
     </SPAN>
     <% } %>
</FONT>
</BODY>
</head>
<frameset rows="170,*" onLoad='initializeTree()'>
<frame name="banner" scrolling="no" noresize target="contents" src="Menu.html" frameborder="no">
<frameset cols="150,*">
<frame name="treeFrame" frameborder="no" src="blank.html">
<frame name="folderFrame" src="AllResources.html" frameborder="no">
</frameset>
</frameset>
</html>
This is the jsp that displays the tree, you can either manually code the SPAN_IDs to include watever u want in the tree or you can get the contents of the tree from the database.

Similar Messages

  • Exercise / display tree in JSP

    Until recently, I though it was not possible to display a tree
    with JSP pages unless using some "external" code [tag,js,etc.] for
    generating the HTML.
    So I propose you a little challenge:
    - display a tree [for example a directory structure starting from a given directory]
    - in a nested form
    - with no library tags
    - without direct use of "out"
    - <%= ... %> only allowed to display file names
    - with a single JSP

    what you want ommit is all the advantage of the jsp:(()
    without those, why people use jsp?My purpose is only to demonstrate that it is possible to display
    a nested structure with "simplistic" JSP. So, will you take up the challenge ?

  • Graphical tree in JSP

    I wanna write a code that will allow users to make a tree structure at runtime, it must be a web based server site most preferably in JSP

    cotton.m,
    Unless you are planning to use an applet this won't be happening.Exactly and this is what happened to me when I tried to implement table tree in jsp and javascript, after several approach; it turn out the is no way of controlling the view; then I moved to build the Report based on applet
    You don't seem to be aware that JSP code executes on the server. And produces something like HTML. Which is then viewed in the browser.Yes and It is not easy to handle the event on the browser to the server; especially if you want to use one component from Struts or any rich client interface framwork, you will end up adding the whole libraries and different configurations etc.. so there is not light weight approach to extract what you need from these frame work (ZK, Struts, Myfaces etc..)
    Regards,
    Alan Mehio
    London,UK

  • Urgent : Trees in JSP

    hii guys
    i am very new to jsp..i want to display a employee hierachy structure( who reports to whom)..
    current i am using java swing tree and loading it in applet..but this is giving me problem because of the large size of driver file..
    i would like to know if i can embed swing tree or any other tree which jsp supports.i want to update the tree dynamically i.e when the user clicks on a employee i wnat to expand it to show who reports under him...
    plzzz reply very soon..thanks
    sairam

    JSP has no native support for displaying trees. Hence I have created a tag library to solve the problem
    http://www.jenkov.dk/projects/treetag/treetag.jsp
    Jakob Jenkov
    www.jenkov.dk

  • Problem in impelementing tree in jsp using XML

    I am trying to impelemnt "treeview.htc" to impelement tree structure in my jsp page.I am using XML file to get the elements for treenodes.Now My Problem:
    Basically i have one ASP page with me, and there they have done all this things.But when i try to impelement the same thing in JSP it is thrwing me error.
    <b>Error: It is unable to detect the namespace i have mentioned in :>
    IT is not able to detect the "TVNS" namespace..Hence showing error while saving the jsp file</b>
    <code>
    <?XML:NAMESPACE PREFIX=TVNS />
    <?IMPORT NAMESPACE=TVNS IMPLEMENTATION="C:/XMLTREE/treeview.htc" />
    <tvns:treeview id="ctlFilter_TreeFilter" class="clsTreeView"
    defaultStyle="font:normal normal normal 8pt Tahoma;" selectedNodeIndex="0" HelperID="__ctlFilter_TreeFilter_State__" systemImagesPath="C:/XMLTREE/images"
    onexpand="javascript: if (this.clickedNodeIndex != null) this.queueEvent('onexpand', this.clickedNodeIndex)" oncollapse="javascript: if (this.clickedNodeIndex != null) this.queueEvent('oncollapse', this.clickedNodeIndex)"
    oncheck="javascript: if (this.clickedNodeIndex != null) this.queueEvent('oncheck', this.clickedNodeIndex)" onselectedindexchange="javascript: if (event.oldTreeNodeIndex != event.newTreeNodeIndex) this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex)" style="height:100%;width:100%;">
         <tvns:treenode Type="And" Expanded="True" Selected="true">
              And<tvns:treenode Type="Property">
                   Buyer Name = "Abukar Hagi, Abdirashid"
              </tvns:treenode><tvns:treenode Type="Property">
                   Buyer Name > "Abukar Hagi, Abdirashid"
              </tvns:treenode><tvns:treenode Type="Property">
                   Buyer Name <= "Abukar Hagi, Abdirashid"
              </tvns:treenode>
         </tvns:treenode>
    </tvns:treeview>
    </code>
    Please help me out .its very urgent.
    Thanks in advance.

    Have you actually been able to get this to work? I tried some of the demos from the MS site and running the html file with the treeview.htc just sends my browser into a state of loading with nothing happening!?!
    This is a webcontrols component which is rather MS specific. As for finding the namespace, are you accessing this page locally or remotely? the namespace location, if run from a JSP, will resolve the C: drive to the one the web browser is running in not your server.
    If you have your htc file in the same dir as the jsp your running, then putting just "treeview.htc" as the namespace whould be fine or add the context path like so:IMPLEMENTATION="<%=request.getContextPath()%>/treeview.htc"Let me know if you actually get this running without a web server. Otherwise it may be the .Net server that renders the page.
    Anthony

  • Urgent help, Tree Viewer JSP

    Has anyone gotten the tree viewer bean to work on a JSP? If so, please give tips on it, or an example of table would be appreciated. I keep getting an error message that my row-set browser is not self-refferencial.
    Thanks

    hi vidyut, thanks for the help. was juz wondering. The file contents tt im supposed to read in and print out contains around 200 similar entries, meaning :
    MEASURE Waist_Full=33.19
    MEASURE Waist_Front=16.06
    MEASURE Waist_Back=17.12
    MEASURE Waist_Height_Front=38.82
    MEASURE Waist_Height_Back=39.73
    MEASURE Waist_Height_Left=39.28
    MEASURE Waist_Height_Right=39.28
    MEASURE Waist_Front_X=43.98
    MEASURE Waist_Back_X=35.04
    MEASURE Waist_Width=11.85
    MEASURE Shirt_Collar=14.88
    MEASURE Neck2Waist_Front=19.64so is the properties object stil the best method to use? To extract the whole string except MEASURE and '='?

  • JS Tree Browser - JSP

    I have inserted a JS Tree Browser Data Web Bean in a JSP page but it doesnot works!! This is the result:
    "Rowset must be self-referential and ViewLink accessor must be defined"
    ... What should I do??...
    Thanks!!
    Johary Pirez.

    You need to prepare the query using the setWhereClauseParams(x) call, before you initialize your data web bean. Otherwise, if you call the methods after you initialize your web bean, the context has already been set and the error occurs.
    You should insert another data web bean into your page somewhere at the top and use it to setup your query and create a view object. You should remove this bean's Render() method since you are only interested in the Initialize() method here. Add your code to prepare the query and create the view object.
    Then when your JS Tree Browser executes, it will be able to call getRowSet() on the View Object you created already.

  • Hierarchical trees in jsps

    Hello:
    Does anyone have any sample code that shows displaying a
    hierarchical tree from a jsp page?
    We're new at jDeveloper and are using xml and xsl
    stylesheets.
    We cannot use the swing control as this requires the client to
    download a 2mb file to their computer.
    Any advice, samples or links for a solution would be greatly
    appreciated.
    Thanks.
    Sheena

    Check out Coldtags suite on http://www.servletsuite.com/jsp.htm
    There is a Tree taglib

  • Using tag library to create a tree in jsp

    Hi,
    I want to create a tree in a JSP page whose node values are obtained from the database. The number of children of a particular node is known only during the construction of the tree.
    Root
    |---Node I
    |----Node I Level 1 Child 1
    |----Node I Level 1 Child 2
    |----Node I Level 1 Child 2 SubLevel Child 1
    |----Node I Level 1 Child 2 SubLevel Child 2
    |---Node I Level 1 Child 2 SubLevel Child 2 Subsub Level1
    |----Node I Level 1 Child 3
    |---Node I Level 1 Child 3 SubLevel Child 1
    |---Node II
    |---Node n
    These node values are obtained from the database. Any early help is appreciated. Helping in tree construction using JSP & Tag Libraries is requested (not swings). Also help me in deploying the same in Tomcat 4.0 server.
    Regards
    Vimal

    I am not very knowledgable in tag libraries. Bust using pure java, you can do something like this:
    Create Node and NodeRenderer java classes. These classes will have methods to access their siblings, parent and its properties and to render itself using HTML code. When you read the database to retreive the tree structure, you can build a hierarchy of nodes. Each Node can render itself and by doing an appropriate traversal, the tree can be rendered.

  • Tree in JSP

    I am trying to display the values getting from the database and display in the tree to different levels of nodes.I also need to dynamically add a node to the tree.
    So please help me to do the needful if any one has the solution
    thanking you

    http://forum.java.sun.com/thread.jspa?threadID=483984&messageID=2567249

  • Tree view JSp

    hai all,
    i am new to XML. I have the requirement like
    I have a tree structure with parent and child
    It goes upto 30000 records.
    User enters the text and presses submit button the
    coresponding text has to be searched in the tree structure
    and that has to be made selected.
    all the parent node which has the text as child has also
    to be populated in the List box. how can I do this.
    Is it possible to do this in client side ?
    I want help ?
    thanks
    sundar

    Internet Explorer 5 can do it on the client-side. it uses the Active-X plugin as a DOM parser....and you can use javascript with it.

  • Tree View through JSP and Java Script

    Hi,
    I am looking for code or ideas of a Tree Structure as shown in in the left side frame of admin console of Sun App server 7 on the browser. I need to create a tree structure which will work on the browser like it works on the Sun App Server 7 admin console. If you had any idea or code, please share with me. I would like to have some idea before I start building it. The tree will be build from the database. So any database design is also helpful. I am planning to have that tree using JSP and EJB.
    Please help. If you are not clear what I am looking for, then please drop a line in this forum, so that I can explain it fine.
    Thanks in advance.
    Amit

    You can use the JSP Tree Tag I have developed. This helps you both structuring the tree model itself + it takes care of displaying the tree in a nice way. You can change all HTML code used to display the tree. Also you can build trees dynamically instead of just displaying static trees. Take a look at it here:
    http://www.jenkov.dk/projects/treetag/treetag.jsp
    Kind Regards,
    Jakob Jenkov

  • JSP example for Tree requirement

    hi, I can find many Java application example about the Tree in the internet, does any one know where I can find an example for show out a Tree in JSP?
    Regards

    There is a SVG Territory Manager Demo that comes with MapViewer that can be downloaded from OTN. It alows you to select a county on the map and it uses the enableFeatureSelect and getSelectedIdList functioins. If you have not downloaded the latest 10.1.2 mapviewer and the demo data, you can download it from here, http://www.oracle.com/technology/software/products/mapviewer/index.html.
    Basically you need to do the following things to make it work.
    1. In the XML base map definition, set "selectable_in_svg" attribute and onclick function for the theme on which you want feature selection to be enabled . Here is an example,
    <?xml version="1.0" standalone="yes"?>
    <map_definition>
    <theme name="STATES" min_scale="50.0" max_scale="4.0"/>
    <theme name="COUNTIES" min_scale="4.0" max_scale="0.0" min_dist="0.5" selectable_in_svg="true" onclick="selectCounty"/>
    <theme name="STATES_LINE" min_scale="4.0" max_scale="0.0"/>
    <theme name="HIGHWAYS" min_dist="1.0"/>
    <theme name="CITIES" min_scale="1.2" max_scale="0.0" />
    </map_definition>
    2. Define the onclick javascript function in your jsp/html page where the svg map is embedded. For example, if you have created a base map using the sample XML shown above, you should define a javacript function called "selectCounty" to handle the mouse click event when the feature is clicked. Inside this javascript function, you can call getSelectedIdList to get the id of the clicked feature.
    3. In your jsp/html page, call javascript function enableFeatureSelect to enable single feature selection.

  • How to define recursive functions in JSP

    Hi,
    If anybody knows, how to to define recursive functions pls help. I am using an XML file for the creation of a tree menu. In order to display the menu, i have to use recursive functions...Also out.println throwing error in the function..
    Thanks,
    Philips

    I do not have my Java book at work with me today so you'll have to bear with me. The following routine assumes that you can get some sort of branch object from your tree menu object (also assuming you have something like this). Furthermore, it assumes that the branch object can return some sort of collection of all leaves and branches on a particular branch through a made-up getLeaves() method call.
    <%!
              public void displayLeaves(Branch branch)
                   Iterator branches = null;
                   branches = branch.getLeaves().getIterator();
                   Object leaf = null;
                   while( branches.hasMoreItems() )
                        leaf = branches.nextItem();
                        if(leaf instanceof branch)
                             displayLeaves((Branch) leaf);
                        else
                             out.println( ((Leaf)leaf).getValue() );
    %>This code fragment should be just the logic you need to expand a tree as JSP output. To invoke this method all you have to do is pass the root branch element to the method from within your JSP. Please let me know if you need additional info.

  • Detailed Tree Navigation

    Friends,
    I have to develop a custom detailed tree navigation wich will start at the first level.
    In our new design the Top Level Navigation doesn't exists.
    The initial nodes will start collapsed.
    I think I'll have to create a new jsp but I'm new at portal customization.
    Can anyone have some example or tutorial that can help me in this task ?
    Thanks for help,
    Ramatís
    Edited by: Ramatís on Jul 29, 2009 7:29 PM

    Hi Ramatis,
    Here is some of the suggestion I can provide for you:
    1) Develop Navigation tree via JSP - using NavigationTagLibrary Taglibs - Please refer to the following blogs by Sven Kannengiesser, the provided example demostrate the usage of the NavigationTagLibrary and the sucker fish drop down.
    EFP: Working with the new Taglibs - Part 3
    2) Develop Navigation tree via  AbstractPortalComponent - You can find code example in NWDS's help content on how to builde  a Sitemap. This sample shows how to use portal services to populate navigation node. You can blend in your HTML, CSS and JS on top of this sample to create your detailed navigation.
    From the NWDS menu bar -> Help Contents ->SAP NetWeaver Developer Studio Documentation ->Portal Development Manual->Go and Create->Creating a Site Map
    3) Develop Navigation tree via Webdynpro - Using Portal Services - com.sapportals.portal.navigation.INavigationService to get portal navigation node and bind these node to webdynpro Tree UI.
    Edited by: Victor Kong on Jul 30, 2009 7:03 AM

Maybe you are looking for

  • Can you create a FireFox add-on that has the same functionality as Momentum for Chrome?

    Open a new tab that features a beautiful inspirational background photo. Purpose is to keep you on task to achieve your goals - more than a to-do list. "Good Morning, Afternoon or Evening <your name>" Random motivational quote from a library which ca

  • I have a Ipod classic 80 GB

    My ipod has over 10k songs and it works fine. My problem is, I recently bought a new Sony Receiver for my home stereo. The receiver has an ipod dock-usb port. When I plug my ipod into the dock it automatically shows a check mark an reads its OK to di

  • Problem with date format convertion

    Dear All, i want to convert the current system date to particular format that i have specified below in SimpleDateFormat but when ever i exceute my program it comes in different format could you help me to solve the problem DateFormat sdf = new Simpl

  • Sales analysis(amt wise)

    hi,     can i do a sales analysis( selection criteria as amountwise). regards, Vignesh

  • Summarization within the details section

    Post Author: Todd Bailey CA Forum: General I need my report to summarized by a certain field called "asset group".  Examples of this asset group are; Streets, Parks, etc.Other fields include: Total hours, Labor Cost and Equipment Cost Depending on th