Make a dynamic menu using JSP or Javascript

Hi ,
I am trying to make a dynamic menu that is using data retrieved from database in the form of a list.
I have a javascript to make a tree structure menu, but i need to iterate through the list i am reciveing from the database to make the tree structure. here is the code :-
<Please reply ASAP as my deadline is near>
<Note:- in javascript to make static menu ul tag is used to make the parent node and li tag is use to make the child node>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" SRC="mktree.js"></SCRIPT>
<LINK REL="stylesheet" HREF="mktree.css">
</head>
<body>
<%@ page import = "java.util.ArrayList, java.util.Iterator, java.util.List, \WEB-INF\classes\DO_JSP.class,
\WEB-INF\classes\Url_Name.class, java.util.Comparator, java.util.TreeSet, \WEB-INF\classes\MyComp.class" %>
<%
     class Url_Name {
     String linkName;
     String linkUrl;
     int order;
     * @return the order
     public int getOrder() {
          return order;
     * @param order the order to set
     public void setOrder(int order) {
          this.order = order;
     * @return the linkName
     public String getLinkName() {
          return linkName;
     * @param linkName the linkName to set
     public void setLinkName(String linkName) {
          this.linkName = linkName;
     * @return the linkUrl
     public String getLinkUrl() {
          return linkUrl;
     * @param linkUrl the linkUrl to set
     public void setLinkUrl(String linkUrl) {
          this.linkUrl = linkUrl;
class MyComp implements Comparator{
     public int compare(Object a, Object b){
          return (((Url_Name)a).getOrder() - ((Url_Name)b).getOrder());
     class DO_JSP
     int parentId;
     String parentName;
     TreeSet linkList;
     Url_Name tempurl;
     * @return the linkList
     DO_JSP(){
          linkList = new TreeSet(new MyComp());
     public TreeSet getLinkList() {
          return linkList;
     * @param linkList the linkList to set
     public void setLinkList(String linkName, String linkUrl, int order) {
          tempurl = new Url_Name();
          tempurl.setLinkName(linkName);
          tempurl.setLinkUrl(linkUrl);
          tempurl.setOrder(order);
          this.linkList.add(tempurl);
     * @return the parentName
     public String getParentName() {
          return parentName;
     * @param parentName the parentName to set
     public void setParentName(String parentName) {
          this.parentName = parentName;
     * @return the parentId
     public int getParentId() {
          return parentId;
     * @param parentId the parentId to set
     public void setParentId(int parentId) {
          this.parentId = parentId;
%>
<%
          List listdojsp =new ArrayList();
          listdojsp = (List)session.getAttribute("JspListName");
          Iterator it = listdojsp.iterator();
          do
%>
          <%
          DO_JSP tempdojsp = (DO_JSP)it.next();
          String Parent = tempdojsp.getParentName();
          %>
          <ul class="mktree">     
          <li> Parent </li>
               <ul>
          <%
          Iterator ittemp = tempdojsp.getLinkList().iterator();
               do
                    Url_Name tempurlname = new Url_Name();
                    tempurlname = (Url_Name)ittemp.next();
                    String link = tempurlname.getLinkName();
          %>
                    <li>link</li>
          <%
               }while(ittemp.hasNext());
          %>
               </ul>
               </ul>          
          <%     
          }while(it.hasNext());
          %>
</body>
</html>

Hi ,
I am trying to make a dynamic menu that is using data
retrieved from database in the form of a list.
I have a javascript to make a tree structure menu,
but i need to iterate through the list i am reciveing
from the database to make the tree structure. here is
the code :- Hi, do you have a question? This is more of a "Look what I wrote" sort of post, and you don't seem to be asking for any specific advice. Please tell us what problem you're having, or the error message you're receiving.
Brian

Similar Messages

  • How to create two level dynamic list using JSP , Java Script and Oracle

    I am new in JSP. And i am facing problem in creating two level dynamic list using JSP ,Java Script where the listdata will come from Oracle 10g express edition database. Is there any easy way in JSP that is available on in ASP.NET.
    Plz response with details.

    1) Learn JDBC API [http://java.sun.com/docs/books/tutorial/jdbc/index.html].
    2) Create DAO class which contains JDBC code and do all SQL queries and returns or takes ID's or DTO objects.
    3) Learn Servlet API [http://java.sun.com/javaee/5/docs/tutorial/doc/].
    4) Create Servlet class which calls the DAO class, gets the list of DTO's as result, puts it as a request attribute and forwards the request to a JSP page.
    5) Learn JSP and JSTL [http://java.sun.com/javaee/5/docs/tutorial/doc/]. Also learn HTML if you even don't know it.
    6) Create JSP page which uses the JSTL c:forEach tag to access the list of DTO's and iterate over it and prints a HTML list out.
    You don't need Javascript for this.

  • How we can generate dynamic menu in jsp page

    Hi all,
    how we can generate dynamic menu in jsp page.
    Thanks
    Manjinder

    by reading more about them on the web or in a good book, OR BY HIRING SOMEBODY TO DO SO. ;)

  • Dynamic Menu in JSP

    Hi,
    I have to make a menu just like www.staple.com in my JSP. The main product category and sub-category are read from the database. I have classes written which retrieve the product and sub categories but dont know hot to proceed with building of dynamic menu in my JSP. Please let me know how to move forward for this one.
    Thanks

    Hi,
    I tried to do something like this :
    *******CODE*******
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <%@taglib uri="/struts-tags" prefix="s"%>
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
         <style type="text/css">
         body {
              font-family: arial, helvetica, serif;
         #nav, #nav ul { /* all lists */
              padding: 0;
              margin: 0;
              list-style: none;
              float : left;
              width : 11em;
         #nav li { /* all list items */
              position : relative;
              float : left;
              line-height : 1.25em;
              margin-bottom : -1px;
              width: 11em;
         #nav li ul { /* second-level lists */
              position : absolute;
              left: -999em;
              margin-left : 11.05em;
              margin-top : -1.35em;
         #nav li ul ul { /* third-and-above-level lists */
              left: -999em;
         #nav li a {
              width: 11em;
              w\idth : 10em;
              display : block;
              color : black;
              font-weight : bold;
              text-decoration : none;
              background-color : white;
              border : 1px solid black;
              padding : 0 0.5em;
         #nav li a:hover {
              color : white;
              background-color : black;
         #nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {
              left: -999em;
         #nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul { /* lists nested under hovered list items */
              left: auto;
         #content {
              margin-left : 12em;
    </style>
    <script type="text/javascript">
    sfHover = function() {
         var sfEls = document.getElementById("nav").getElementsByTagName("LI");
         for (var i=0; i<sfEls.length; i++) {
              sfEls.onmouseover=function() {
                   this.className+=" sfhover";
              sfEls[i].onmouseout=function() {
                   this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    if (window.attachEvent) window.attachEvent("onload", sfHover);
    //--><!]]></script>
    </head>
    <body>
    <ul id="nav">
         <s:iterator value="productList" id="products">     
                   <li> <s:url id="getProductCategoryCodesURL" action="listProductCategoryCodesByProductCd">
                                                      <s:param name="productCd" value="%{productCd}"></s:param>
                                                 </s:url>                                              
                                                 <s:a href="%{getProductCategoryCodesURL}" ><s:property value="productNm" /></s:a>
                                                 <input type="hidden" id="prodCd" value="<s:property value="productCd" />"/>
                             </li>
    </s:iterator>
    </ul>
    </body>
    </html>
    ****END CODE******
    So i was able to get the product categories in the menu but on mouse hover for a particular product category it should show sub-categories also. I can't think of a way to do that , can anyone please suggest ?

  • Dynamic select using jsp?

    grrrrr............ok so I'm kinda new to this, and just a little frustrated. I'm gonna ramble here, so any time I sound like I don't know what I'm talking about it 's because I don't..correct me. I want to include a bean in a jsp which will buil d a dynamic select box on the fly. That is, connect to an LDAP db and place each value returned in the query in a select box. Now, I can compile and run the bean in my IDE and watch the output in the console. It's correct because I see "<select><option value = hall>hall....</select>". In the buildSelectBox() method I'm using System.out.println to display each line of my select box (is that right?). Now, when I copy the .class file over to the server I was initially getting an error because the bean wasn't found. I resolved that by properly compiling the bean in a package. Problem is that if I call the bean.buildSelect() method in the .jsp nothing comes back. The page is left blank. What in the world is that about? Can someone push me toward a tutorial that can push me in the right direction or sumthin? Why am I having so much trouble with this? Should I be building the select on the jsp?
    regards,
    mat

    Hi!
    If i understand you correctly :-) you are doing not very right things. I don't want it to seem like I'm going to teach you, but:
    The Bean that has buildSelect() method is not a bean at all. Usualy Beans contain getter/setters and accumulate data. If you want to build html code dynamicaly then you should use servlets(Which is not very flexible in your situation, I think), not JSPs. And if you are using JSPs then you have to make Tag which will do this everything.
    Other way is to use Struts framework which is very good and flexible for building web applications - it has it's own tags for many cases. You can make loops in JSPs, use beans and all that stuff.
    Guys will correct me if I missed something.
    Good luck

  • Styling a dynamic menu using CSS

    Hi everyone, hope someone can help.
    I have spent a few hours starting to style a new site and i am struggling with the dynamic menu
    http://www.innovas.co.uk/ourclients.htm
    what i would like it to do is have a gap in between each of the main menu items so that its not one consistent block of grey background colour. I have tried isolating the style for tr. and adding a border-padding of 1px with a color white, but this adds the border to all table rows. i just need a way of styling a 1px white border into the menu item layout.
    some help would be hugely appreciated
    thanks in advance
    Phill

    Hello!
    The best way to approach this would be to use Dynamic Menu v2. It will save you a lot of hassle.
    There's a thorough explanation covered in this post: http://forums.adobe.com/docs/DOC-1903.
    Let me know how it goes.

  • How to get a dynamic pages using jsp?

    actually using jsp we create static pages.
    My question is whether it is possible to create dynamic pages. ie the page should reflect changes without refreshing or reloading. for example we have date timings frequently updated without refreshing

    Read Beginning JSP from WROX Press. It is a good book for developing dynamic JSP using all latest technologies.

  • Dynamic combobox using jsp

    HI All,
    This is very urgent for me please help me to come out of this.
    I just want to display the values in combobox from database using jsp,but i have difficulty in doing it can any one help me for this.I will be thankfull if any one gives me a code for the same.
    Ramesh.R

    very simple example
    <%@ page import="java.sql.*" %>
    Add Item:
    <SELECT NAME="item">
    <ol>
    <%
    Connection con5 =
    DriverManager.getConnection("url","user","password");
    String q5 = "query" ;
    Statement stmt5 = (Statement)con5.createStatement();
    ResultSet rs5 = stmt5.executeQuery(q5);
    while(rs5.next()){
    String str5= rs5.getString("field");
    %>
    <li> <% out.print("<OPTION>" + str5); %>
    <% } %>
    </ol>
    </SELECT>

  • Cancel- and main-button dynamically generated using JSP-pages

    Maybe a HOWTO for the Jdev-team.
    HOWTO get rid of the delete and main-button in your jsp-pages?
    Very simple!
    Go to the container_bottom.jsp page in your webapp/jsp-folder and delete the code for the cancel-button => now the user can render his own buttons by using a header.html, contents.jsp and footer.html for the jsp-pages.

    We tried the same thing you are trying to do and got
    very far, but it quickly became very complicated. We
    realized it was just simpler to use the screenflow as
    intended.
    By this I mean, if your parent form has 4 buttons
    (A,B, C and SUBMIT), you should design different
    paths in your screen flow for each button. so when a
    user clicks button A, the parent form submits back to
    Fuego engine, engine looks at screenflow and send
    them down the button A path to the Form A. When they
    hit submit on Form A, screenflow goes back to parent
    form.Hi, bcespinola:
    Our team finally decide use jsp with YUI (Yahoo User Interface Library) to achieve this design. Wish this could help you. All popup window would be replaced by Dialog of YUI. Thanks for your help.
    Vince

  • KB3008923 Makes Microsoft Dynamic CRM 2013 add/change javascript in Form Dialog impossible - Fix is use CHROME or remove update.

    After KB3008923 was installed on my computer we found out that in Microsoft Dynamic Crm 2013
    we could not change Form Script or add Form scripts as the dialog adding/maintaining this did not work
    any more. The dropdown box is empty and the function and parameters are gone.
    Fix is to remove KB3008923 or use CHROME until Microsoft fixes  it! 

    REPOSTING...
    Some web application modal dialog boxes don't work correctly in Internet Explorer 11 after you install update 3008923 (17 Dec-14)
    http://support2.microsoft.com/kb/3025390/en-us
    ~Robear Dyer (PA Bear) MS MVP-Windows Client since 2002 Disclaimer: MS MVPs neither represent nor work for Microsoft

  • Loading data in a drop down menu using jsp

    hello everyone...
    I'm very new to JSP programming....i'm facing a problem regarding loading the data in a drop down menu at the button click.....
    what i'm doing is...i'v taken a button and at the button click the data from "Sql Server 2000" shd load in a drop down menu....here's the code which i think will make my point clear....
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <%
              Connection con=null;
              ResultSet rs=null;
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbc:odbc:p_portal");
                   Statement stat=con.createStatement();
                   String sql="select * from message_box where name='anindo'";
                   rs=stat.executeQuery(sql);
                   %>
    <script language="javascript">
    function check()
         var show=document.getElementById("mydivtag");
         show.innerHTML = "<label><select name=select><% while(rs.next()){%><option><%= rs.getString(1) %></option><option><%= rs.getString(2) %></option><option><%= rs.getString(3).substring(0,10) %></option></select></label><%}}catch(Exception ex){out.print("Exception is:- "+ex);}%>";
    </script>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="">
      <label></label>
      <p>       
        <input type="submit" name="Submit" value="Submit" onclick="check()" />
           </p>
      <p>       
       </p>
      <div id="mydivtag" ></div>
      <p> </p>
    </form>
    </body>
    </html>

    yep Ajax is d right way 2 do so.
    So can use DWR(ajax tech.) for dis/
    To implement dis dere r simple steps u hav 2 follow
    1. entry for <dwr> tag in web.xml
    2. entry for <onverter>in web.xml
    3. In jsp u write
    <script type="text/javascript" src="<%=appName%>/dwr/engine.js"></script>
    <script type="text/javascript" src="<%=appName%>/dwr/util.js"></script>
    <script type="text/javascript"src="<%=appName%>/dwr/interface/ClassService.js"></script>
    were ClassService is ur class whose method u want 2 call.
    4.
    In jsp under <script> u can simply write
    ClassService.Methodname(param1,param2,....,CallBackFunction);
    5.CallBackFunction(data)
    /// do wt u want
    For more details u can find it on google.

  • How to build dynamic menus using JSP==Urgent==Please Help me

    Hello,
    I have exhausted searching on internet to find a book
    which tells how to build Dynmic menus in JSP.I dont want
    to use DHTML as this becomes complex as the menu categories
    are built using data from database.Is there any workaround in
    java to do this without DHTML or atleast sample code.
    can somebody help me in this regard.
    Thanks
    Jack

    Hello a.s.kumar,
    I would be greatful if you could send me the sample code.
    [email protected]
    we can't let MM Flash run away with the show can we. Javascript can do a decent job, but the underlying menu data is static.
    Cheers, Darren

  • How to make side navigation menu using ADF

    Hi,
    I wanted to make a side navigation menu, like, there is a vertical menu and if I place the cursor on(or select) one of the menu item and it shows the children menu items sideways( having go links).
    How can I achieve that?
    I am using Jdev 10.1.3.3

    If I understand your requirement you're looking for something like this: http://deluxe-menu.com/sound-support-sample.html
    Under 10.1.3 using ADF Faces I don't believe there is a component available to achieve this. Potentially under 10.1.3 you'll need to look to a 3rd party Javascript solution. Whether this will work with ADF Faces + JSF navigation is questionable. Potentially others on the forum can comment.
    As an alternative solution under 10.1.3 you may want to look at using an af:tree component instead. It wont be as nice as the solution shown above, but will give you a multilevel menu selection.
    Regards,
    CM.

  • XMLDataSet and Dynamic XML using JSP

    I am trying to use the XMLDataSet function to call a jsp page
    instead of an xml file. The jsp page fetches records out of a db
    and creates xml to return to the spry function. Nothing seems to be
    returned, and blank spry data region on page.
    If i supply a xml file to the function it works correctly.
    I adapted the ASP/PHP samples from XMLExport demo. Code as
    follows:- If i run 2nd jsp directly, the browser shows the xml as
    expected.
    --- TEST.JSP ---
    <script type="text/javascript">
    Spry.Data.Region.debug=true;
    var dsPeople = new Spry.Data.XMLDataSet("transtoxml.jsp",
    "company/person");
    </script>
    --- transtoxml.jsp ---
    <%@ page language="java"
    import="java.sql.*, java.io.*, java.util.*,
    com.Ostermiller.util.*"
    errorPage="" %>
    <%@ include file="globals.jsp" %>
    <%
    String SQL="";
    Statement sTransaction;
    ResultSet rTransaction;
    try
    Class.forName(className);
    con =
    java.sql.DriverManager.getConnection(connectionURL,userName,password);
    }catch(Exception e){
    out.print(e.toString());
    out.print("Error connecting to database " + connectionURL);
    SQL ="SELECT ";
    SQL+="[ID], ";
    SQL+="[DocumentNo]";
    SQL+="FROM TRX_TRANSACTION_MAPPING";
    sTransaction = con.createStatement();
    try {
    rTransaction = sTransaction.executeQuery(SQL);
    response.setContentType("text/xml");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("pragma","no-cache");
    %>
    <?xml version='1.0' encoding='iso-8859-1'?>
    <company>
    <% while(rTransaction.next()) { %>
    <person>
    <id><%=(rTransaction.getString("ID"))%></id>
    </person>
    <% } %>
    </company>
    <%
    response.flushBuffer();
    sTransaction.close();
    } catch (SQLException e) {
    out.print(e);
    %>

    This is the xml output the jsp gives when run directly:- Cut
    n pasted from browser. There does appear to be an error, because
    the spry:state="error" div is being displayed. If i paste the
    following into a file all is ok, any ideas anyone.
    regards
    sm@rt
    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <company>
    - <person>
    <id>117</id>
    </person>
    - <person>
    <id>118</id>
    </person>
    - <person>
    <id>119</id>
    </person>
    - <person>
    <id>120</id>
    </person>
    - <person>
    <id>121</id>
    </person>
    - <person>
    <id>122</id>
    </person>
    - <person>
    <id>123</id>
    </person>
    - <person>
    <id>124</id>
    </person>
    - <person>
    <id>125</id>
    </person>
    - <person>
    <id>126</id>
    </person>
    - <person>
    <id>127</id>
    </person>
    - <person>
    <id>128</id>
    </person>
    - <person>
    <id>129</id>
    </person>
    - <person>
    <id>130</id>
    </person>
    - <person>
    <id>131</id>
    </person>
    - <person>
    <id>132</id>
    </person>
    - <person>
    <id>133</id>
    </person>
    - <person>
    <id>134</id>
    </person>
    - <person>
    <id>135</id>
    </person>
    - <person>
    <id>136</id>
    </person>
    - <person>
    <id>137</id>
    </person>
    - <person>
    <id>138</id>
    </person>
    - <person>
    <id>139</id>
    </person>
    - <person>
    <id>141</id>
    </person>
    </company>

  • Make a grid menu using an array

    Hi,
    I was wondering if there is a way to make a menu of buttons from an array arrange themselves in a 3x3 grid.
    I have used code i have gotten from this forum to place them next to each other onto the stage (which was quit awesome) and i have found code to place them in a rotating cell from an array but is it possible to do it as a grid?
    Any help would be great

    use Math.floor and the modulo operator to construct grids:
    var xSpace:int = 100;
    var ySpace:int=100;
    var rowNum:int=3;
    var colNum:int=3;
    for(var i:int=0;i<yourarray.length;i++){
    yourarray[i].x=xSpace*i%rowNum;
    yourarray[i].y=ySpace*Math.floor(i/colNum);

Maybe you are looking for

  • Need a formula for a date in one table to show on a calendar on a "summary" sheet

    Hello, I have created a simple table for my daughter to keep track of her monthly bill's due dates which are in one row of the table. I'd like to create a "summary" sheet which consists of a calendar that shows those dates at one look, it would also

  • Only one Extractor source is allowed in a data flow ?

    Hi, We have a common scenario (I think this is common for SAP ECC in general) where we have 2 tables, *_ATTR (Attributes) and *_TEXT (descriptions).  We extract these using extractors. Initially when we tried to place 2 in a dataflow, we got an error

  • Pop up in PO

    Hi All, When account assigned POs are being made, need a pop-up for entering cost centers & GL codes. This was coming earlier but now it is not. Please suggest. Regards Praveen

  • Watermark, color space, and transparency problem

    I'm having a problem with inserting a watermark image into my pdfs. I created the watermark image in Photoshop. It is 8-bit gray with a transparent background. I saved it as a pdf (pdf 1.4 to allow transparency). The main pdfs (to be watermarked) are

  • Using Customize grouping and filtering for EPPM 8.2.1 family

    Are there any know issues or BUGS when using customize grouping and filtering returing more than the filtered projects? We are customizing grouping on Project Status and Region and filtering on Region and Let by Code Thanks