Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript + JSP + Object Expected (error)

    Hi All,
    I am new Javascript and I got sample code for create tree menu in online and modified then I tried those code to create tree menu using javascript's gFld() and insFld() function but i am getting error like below

    Line: 26
    Char:1
    Error: Object expected
    Code:0
    URL:http://localhost:8080/Statstical-Rep...tLeftFrame.jsp

    I tried my level best but not able to fix that issue. Can some help me to fix that issue?


    statsticalReportLeftFrame.jsp:
    **********************

    <%@ page contentType="text/html; charset=iso-8859-1" import="java.io.File,java.util.ArrayList,java.util.HashMap,java.util.Iterator,java.util.List,java.ut il.Map,java.util.Set,java.io.IOException,java.lang.String" errorPage="" %>

    <%!
    private StringBuffer dir = new StringBuffer("C:\\SurroundSimulation_SVN_New1\\Statstical-Report\\flows\\");
    private List<String> connceiontPointList = new ArrayList<String>();
    private Map<String,List<String>> cpMapWithDate = new HashMap<String,List<String>>();
    private Map<String,List<String>> dateMapWithBound = new HashMap<String,List<String>>();
    private Map<String,List<String>> boundMapWithHtml = new HashMap<String,List<String>>();
    private JspWriter out= null;

    public void initializeStatsticalReportTree(JspWriter out)
    {
    this.out = out;
    File folder = new File(dir.toString());
    File[] listOfFiles = folder.listFiles();
    for(int i = 0; i < listOfFiles.length; i++)
    {
    if (listOfFiles[i].isFile()) {
    System.out.println("[FILE]" + listOfFiles[i].getName());
    }else if(listOfFiles[i].isDirectory()) {
    String directoryToSearch = listOfFiles[i].getName();
    System.out.println("[DIR]" + directoryToSearch);
    dir.append(directoryToSearch+"\\");

    boolean containsCp = connceiontPointList.contains(listOfFiles[i].getName());
    if(!containsCp){
    connceiontPointList.add(listOfFiles[i].getName());

    File subFolder = new File(dir.toString());
    File[] listOfSubFiles = subFolder.listFiles();
    for(int j = 0; j < listOfSubFiles.length; j++)
    {
    if(listOfSubFiles[i].isFile())
    {
    System.out.println("[FILE]" + listOfSubFiles[i].getName());
    }else if(listOfSubFiles[i].isDirectory()) {
    System.out.println("\t[DIR]" + listOfSubFiles[j].getName());

    String directoryToSearch1 = listOfSubFiles[j].getName();
    dir.append(directoryToSearch1+"\\");

    boolean containsCpId = cpMapWithDate.containsKey(listOfFiles[i].getName());
    if(containsCpId){
    List<String> cpIdList = cpMapWithDate.get(listOfFiles[i].getName());
    boolean containsDate = cpIdList.contains(listOfFiles[i].getName()+"/"+listOfSubFiles[j].getName());
    if(!containsDate){
    cpIdList.add(listOfFiles[i].getName()+"/"+listOfSubFiles[j].getName());
    }
    }else{
    ArrayList<String> cpMapWithDateList = new ArrayList<String>();
    cpMapWithDateList.add(listOfFiles[i].getName()+"/"+listOfSubFiles[j].getName());
    cpMapWithDate.put(listOfFiles[i].getName(), cpMapWithDateList);
    }

    File innerSubFolder = new File(dir.toString());
    File[] innerSubFolderFiles = innerSubFolder.listFiles();

    for (int l = 0; l < innerSubFolderFiles.length; l++)
    {
    if (innerSubFolderFiles[l].isFile())
    {
    System.out.println(" [FILE]" + innerSubFolderFiles[l].getName());
    }
    else if(innerSubFolderFiles[l].isDirectory()) {
    String directoryToSearch2 = innerSubFolderFiles[l].getName();
    System.out.println(" [DIR]" + directoryToSearch2);
    dir.append(directoryToSearch2+"\\");


    boolean containsdatefolder = dateMapWithBound.containsKey(directoryToSearch+"/"+listOfSubFiles[j].getName());
    if(containsdatefolder){
    List<String> dateFolderList = dateMapWithBound.get(directoryToSearch+"/"+listOfSubFiles[j].getName());
    boolean containsBound = dateFolderList.contains(directoryToSearch+"/"+listOfSubFiles[j].getName()+"/"+innerSubFolderFiles[l].getName());
    if(!containsBound){
    dateFolderList.add(directoryToSearch+"/"+listOfSubFiles[j].getName()+"/"+innerSubFolderFiles[l].getName());
    }
    }else{
    ArrayList<String> dateMapWithBoundList = new ArrayList<String>();
    dateMapWithBoundList.add(directoryToSearch+"/"+listOfSubFiles[j].getName()+"/"+innerSubFolderFiles[l].getName());
    dateMapWithBound.put(directoryToSearch+"/"+listOfSubFiles[j].getName(), dateMapWithBoundList);
    }

    File innerSubFolder1 = new File(dir.toString());
    File[] listOfSubFiles1 = innerSubFolder1.listFiles();
    for (int m = 0; m < listOfSubFiles1.length; m++)
    {
    if (listOfSubFiles1[m].isFile())
    {
    System.out.println(" [FILE]" + listOfSubFiles1[m].getName());

    boolean containsHtmlfolder = boundMapWithHtml.containsKey(directoryToSearch+"/"+listOfSubFiles[j].getName()+"/"+innerSubFolderFiles[l].getName());
    if(containsHtmlfolder){
    List<String> htmlFolderList = boundMapWithHtml.get(directoryToSearch+"/"+listOfSubFiles[j].getName()+"/"+innerSubFolderFiles[l].getName());
    boolean containsBound = htmlFolderList.contains(listOfSubFiles1[m].getName());
    if(!containsBound){
    htmlFolderList.add(listOfSubFiles1[m].getName());
    }
    }else{
    ArrayList<String> boundMapWithHtmlList = new ArrayList<String>();
    boundMapWithHtmlList.add(listOfSubFiles1[m].getName());
    boundMapWithHtml.put(directoryToSearch+"/"+listOfSubFiles[j].getName()+"/"+innerSubFolderFiles[l].getName(), boundMapWithHtmlList);
    }
    }
    }
    dir.delete(dir.indexOf(directoryToSearch2), dir.length());
    }
    }
    dir.delete(dir.indexOf(directoryToSearch1), dir.length());
    }
    }
    dir.delete(dir.indexOf(directoryToSearch), dir.length());
    }
    }
    }

    try{
    out.print("foldersTree = gFld('<i>Statstical Report</i>','Test.html')" + "\n");
    Iterator<String> cpListItr = connceiontPointList.iterator();
    while(cpListItr.hasNext())
    {
    String cpName = cpListItr.next();
    out.print(cpName + " = insFld(foldersTree, gFld('" + cpName + "','Test.html'))" + "\n");

    }
    }catch(IOException e){
    e.printStackTrace();
    }
    }
    %>


    <html>
    <head>
    <title>Statstical Report</title>
    <style type="text/css">
    BODY {background-color: white}
    TD {font-size: 10pt;
    font-family: verdana,helvetica;
    text-decoration: none;
    white-space:nowrap;}
    A {text-decoration: none;
    color: black}
    </style>
    <script language="javascript" src="ua.js"></script>
    <script language="javascript" src="ftiens4.js"></script>
    <script language="javascript">
    USETEXTLINKS = 1
    STARTALLOPEN = 1
    PRESERVESTATE = 1
    ICONPATH = ''
    HIGHLIGHT = 1
    <%
    initializeStatsticalReportTree(out);
    %>
    </script>
    </head>

    <body topmargin=16 marginheight=16>
    <div style="position:absolute; top:0; left:0; "><table border=0><tr><td><font size=-2><a style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>JavaScript Tree Menu</a></font></td></tr></table></div>
    <script language="javascript" src="ftiens4.js">
    initializeDocument();
    </script>
    <noscript>
    A tree for site navigation will open here if you enable JavaScript in your browser.
    </noscript>
    </body>
    </html>


    View source for statsticalReportLeftFrame.jsp:
    ***********************************
    <html>
    <head>
    <title>Statstical Report</title>
    <style type="text/css">
    BODY {background-color: white}
    TD {font-size: 10pt;
    font-family: verdana,helvetica;
    text-decoration: none;
    white-space:nowrap;}
    A {text-decoration: none;
    color: black}
    </style>
    <script language="javascript" src="ua.js"></script>
    <script language="javascript" src="ftiens4.js"></script>
    <script language="javascript">
    USETEXTLINKS = 1
    STARTALLOPEN = 1
    PRESERVESTATE = 1
    ICONPATH = ''
    HIGHLIGHT = 1
    foldersTree = gFld('<i>Statstical Report</i>','Test.html')
    GTW = insFld(foldersTree, gFld('GTW','Test.html'))
    UL_COSMOS_ONSITE = insFld(foldersTree, gFld('UL_COSMOS_ONSITE','Test.html'))

    </script>
    </head>

    <body topmargin=16 marginheight=16>
    <div style="position:absolute; top:0; left:0; "><table border=0><tr><td><font size=-2><a style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>JavaScript Tree Menu</a></font></td></tr></table></div>
    <script language="javascript" src="ftiens4.js">
    initializeDocument();
    </script>
    <noscript>
    A tree for site navigation will open here if you enable JavaScript in your browser.
    </noscript>
    </body>
    </html>


    Thanks,
    Sidiq

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    We can't help you without the contents of those ".js" files.

    For example, for me the function gFld( ) is undefind.

    Can you show this live, online??


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •