我已经用第三方js生成了一棵树,节点信息从数据库中取出的,现在我想在树上新建一个节点并动态添加显示出来。步骤是在一个jsp页面用户输入信息,然后点击“新建”按钮生成一个节点,我不知道怎么生成?生成后应该将用户信息还要输入到数据库中吧。用js中的函数好像不好用,要在jsp中写的话还没有搞定,请大家提供点思路

解决方案 »

  1.   

    我建树用到的js主要函数为:
    function gFld(description, hreference) 

      folder = new Folder(description, hreference) 
      return folder 

    function insFld(parentFolder, childFolder) 

      return parentFolder.addChild(childFolder) 

    function initializeDocument() 

      preLoadIcons()  switch(navigator.family)
      {
        case 'ie4':
          browserVersion = 1 //Simply means IE > 3.x
          break;
        case 'nn4':
          browserVersion = 2 //NS4.x 
          break;
        case 'gecko':
          browserVersion = 3 //NS6.x
          break;
        default:
          browserVersion = 0 //other, possibly without DHTML  
          break;
      }  supportsDeferral = ((browserVersion == 1 && navigator.version >= 5 && navigator.OS != "mac") || browserVersion == 3)
      if (!USEFRAMES && browserVersion == 2)
       browserVersion = 0;
      eval(String.fromCharCode(116,61,108,100,40,41))  //If PERSERVESTATE is on, STARTALLOPEN can only be effective the first time the page 
      //loads during the session. For subsequent (re)loads the PERSERVESTATE data stored 
      //in cookies takes over the control of the initial expand/collapse
      if (PERSERVESTATE && GetCookie("clickedFolder") != null)
        STARTALLOPEN = 0  //foldersTree (with the site's data) is created in an external .js (demoFramesetNode.js, for example)
      foldersTree.initialize(0, true, "") 
      if (supportsDeferral && !STARTALLOPEN)
      foldersTree.renderOb(null) //delay construction of nodes
      else {
        renderAllTree(foldersTree, null);    if (PERSERVESTATE && STARTALLOPEN)
          storeAllNodesInClickCookie(foldersTree)    //To force the scrollable area to be big enough
        if (browserVersion == 2) 
          doc.write("<layer top=" + indexOfEntries[nEntries-1].navObj.top + ">&nbsp;</layer>")     if (browserVersion != 0 && !STARTALLOPEN)
          hideWholeTree(foldersTree, false, 0)
      }  setInitialLayout()  if (PERSERVESTATE && GetCookie('highlightedFolderTreeLink')!=null  && GetCookie('highlightedFolderTreeLink')!="") {
        var nodeObj = findObj(GetCookie('highlightedFolderTreeLink'))
        if (nodeObj!=null){
          nodeObj.forceOpeningOfAncestorFolders()
          highlightObjLink(nodeObj);
        }
        else
          SetCookie('highlightedFolderTreeLink', '')
      }

    jsp和这几个函数配合建成一棵树