欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

不用迭代算法而快速实现的jsp树结构 算法数据结构JSPXPSQL 

程序员文章站 2022-07-12 16:27:05
...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0049)http://duduwolf.360doc.com/showWeb/0/0/30580.aspx -->
<HTML><HEAD><TITLE>不用迭代算法而快速实现的jsp树结构</TITLE>
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<META content=360doc name=classification>
<META content=不用迭代算法而快速实现的jsp树结构 name=keywords>
<META content=不用迭代算法而快速实现的jsp树结构 name=description>
<META content=www.360doc.com name=author>
<STYLE>.Title01 {
FONT-SIZE: 12px; COLOR: #004499; LINE-HEIGHT: 20px; FONT-FAMILY: arial, helvetica
}
.Title01 A {
COLOR: #0077cc; TEXT-DECORATION: none
}
.Title01 A:hover {
COLOR: #997722; TEXT-DECORATION: none
}
.Title01 A:visited {
TEXT-DECORATION: none
}
.TitleDate {
FONT-WEIGHT: bold; FONT-SIZE: 10px; COLOR: #999999; FONT-FAMILY: arial, helvetica
}
.TitleContent {
FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 20px; FONT-FAMILY: arial, helvetica
}
.TitleContent A {
COLOR: #0077cc; TEXT-DECORATION: none
}
.TitleContent A:hover {
COLOR: #997722; TEXT-DECORATION: none
}
.TitleContent A:visited {
TEXT-DECORATION: none
}
.p2 {
FONT-SIZE: 12px; LINE-HEIGHT: 24px
}
.p2 A:visited {
COLOR: #261cdc
}
.p3 {
FONT-FAMILY: arial
}
.p3 {
FONT-SIZE: 9pt; LINE-HEIGHT: 18px
}
</STYLE>

<SCRIPT language=javascript>
<!--
//-->
</SCRIPT>

<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY text=#000000 bottomMargin=0 vLink=#261cdc link=#261cdc bgColor=#ffffff
topMargin=1>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD><A href="http://duduwolf.360doc.com/index.aspx" target=_blank><IMG
      src="不用迭代算法而快速实现的jsp树结构.files/iDocumentBanner.gif" border=0></A></TD>
    <TD align=middle><A href="http://duduwolf.360doc.com/index.aspx"
      target=_blank><IMG src="不用迭代算法而快速实现的jsp树结构.files/360docAd.gif"
      border=0></A></TD></TR>
  <TR>
    <TD align=middle height=3></TD></TR>
  <TR>
    <TD colSpan=2>
      <TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" border=0
      valign="top">
        <TBODY>
        <TR bgColor=#fffcf4 height=22>
          <TD class=p2>不用迭代算法而快速实现的jsp树结构(转载)&<FONT color=#6f6f6f
            size=1>05.11.14 </FONT>&<FONT color=#6f6f6f>from </FONT><A
            href="http://duduwolf.360doc.com/UserHome/677.aspx">smoking_boy</A> <NOBR><A
            href="http://www.chinaitpower.com/A/2005-06-16/150031.html">来源</A> </NOBR>
          </TD>
          <TD class=p2 align=right width=120><A
            href="http://duduwolf.360doc.com/showWeb/0/1/31209.aspx">上一篇</A>&&&&<A
            href="http://duduwolf.360doc.com/showWeb/0/1/30257.aspx">下一篇</A>&&&&</TD></TR></TBODY></TABLE>
      <TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" border=0
      valign="top">
        <TBODY>
        <TR bgColor=#fdf9e7 height=22>
          <TD class=p2></TD>
          <TD class=p2 align=right><FONT face=楷体_GB2312>这篇文章不错,<A
            href="http://duduwolf.360doc.com/ReSaveMenu.aspx?ArticleID=30580">我也要收藏</A>&&&&</FONT>
          </TD></TR></TBODY></TABLE></TD></TR>
  <TR></TR></TBODY></TABLE>
<TABLE>
  <TBODY>
  <TR>
    <TD>
      <P>在web页面上实现树状结构,有点麻烦.<BR>在最近的一个MIS<A
      href="http://www.chinaitpower.com/System/index.html"
      target=_blank>系统</A>的开发中,我们项目组大量用到了树结构:比如人员的选择,单位的选择等待.<BR>这个MIS<A
      href="http://www.chinaitpower.com/System/index.html"
      target=_blank>系统</A>所用的<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>是oracle 9i.& oracle 9i 的<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>支持迭代查询.我们的树是由牛人彭越写的,不过<BR>也参照了<A
      href="http://www.chinaitpower.com/Net/index.html"
      target=_blank>网络</A>上比较著名的xtree(可以到此下载:http://webfx.eae.net/),他的树算法支持无限级的树结构,不过性能好像<BR>很慢.我持保留态度.<BR>他用到的关键技术就是这句话:<BR>String
      <A href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A> = "select dwxh,dwbh,dwmc,dwfxh,level cc from xt_dw
      connect by& prior dwxh = dwfxh start with dwfxh = 0";<BR>可是许多<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>不支持迭代查询,并且迭代查询速度真是不能忍受.有什么更好的办法呢.下面说说我的解决方案.</P>
      <P>一:需求的提出<BR>1:客户需要一个关于部门人员的树结构,<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>为my<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>4.1<BR>2:<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>实现<BR>二:建表:<BR>1:<BR>用户信息表:<BR>各字段为:用户序号,用户编号,用户名称,单位序号,密码,用户登陆号<BR>create
      table XT_YH<BR>(<BR>& YHXH& INT(9) NOT NULL auto_increment
      PRIMARY KEY,<BR>& YHBH& VARCHAR(30),<BR>& YHMC&
      VARCHAR(30),<BR>& DWXH& INT(9),<BR>& PWD&&
      VARCHAR(20),<BR>& YHDLH VARCHAR(30)<BR>)<BR>--插入三条测试数据:<BR>--insert
      into xt_yh(yhbh,yhmc,dwxh,pwd,yhdlh)
      values('licl','李春雷',2,'password','licl')<BR>--insert into
      xt_yh(yhbh,yhmc,dwxh,pwd,yhdlh)
      values('fengx','冯欣',2,'password','fengx')<BR>--insert into
      xt_yh(yhbh,yhmc,dwxh,pwd,yhdlh)
      values('wangqx','王庆香',6,'password','wangqx')<BR>2:<BR>单位部门表<BR>各字段为:单位序号,单位编号,单位名称,单位父序号<BR>create
      table XT_DW<BR>(<BR>& DWXH& int(9) NOT NULL auto_increment
      PRIMARY KEY,<BR>& DWBH& VARCHAR(10),<BR>& DWMC&
      VARCHAR(30),<BR>& DWFXH int(9)<BR>)<BR>--插入5条测试数据<BR>--insert into
      xt_dw(dwbh,dwmc,dwfxh) values('0100000000','武汉科技局',0);<BR>--insert into
      xt_dw(dwbh,dwmc,dwfxh) values('0101000000','人事处',1);<BR>--insert into
      xt_dw(dwbh,dwmc,dwfxh) values('0102000000','后勤处',1);<BR>--insert into
      xt_dw(dwbh,dwmc,dwfxh) values('0101010000','人事处son1',2);<BR>--insert into
      xt_dw(dwbh,dwmc,dwfxh) values('0101020000','人事处son2',2);<BR>--insert into
      xt_dw(dwbh,dwmc,dwfxh) values('0102010000','后勤处son1',3);</P>
      <P>注意:<BR>为了实现快速的树结构实现,我需要充分利用单位编号DWBH,DWBH才有10位编码,其中,第一第二位表示一级单位,第三第四位表示二级单位,<BR>第五六位表示三级单位...那么10位编码就可以实现五级单位的树结构.<BR>比如:测试数据的树结构如下:<BR>&
      1& 武汉科技局:<BR>&2& 人事处<BR>&&3&
      人事处son1<BR>&&3& 人事处son2<BR>&2&
      后勤处<BR>&&3后勤处son1</P>
      <P>其实XT_DW表中的父序号是多余的.不过如果你要用迭代算法来实现,就是必须的<BR>才有10位编码,我只需要一句简单快速的<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>语句就可以实现树结构:<BR>String <A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A> = "select dwxh,dwbh,dwmc,dwfxh from xt_dw order by
      dwbh"<BR>这句<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>在几乎所有的<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>平台都能执行,速度也快.<BR>下面贴出采用xtree,用10位编码而不是迭代算法实现的树:</P>
      <P>/*******Constants.<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>**********/</P>
      <P>package com.lcl.common;</P>
      <P>public class Constants {<BR>&<BR>&public static final String
      DBDRIVER = "com.my<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>.jdbc.Driver";&&&
      //MYSQL驱动<BR>&<BR>&public static final String DBUrl="jdbc:my<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>://localhost/beauoa"; //<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>url<BR>&<BR>&public static final String
      USERNAME="root";&&&&&&&&&&&&&&&&&&&&&&
      //<A href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>用户名<BR>&<BR>&public static final String
      PASSWORD="root";&&&& //<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>密码<BR>&<BR>&<BR>}</P>
      <P><BR>/**********DbAccess.<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>****************/</P>
      <P>package com.lcl.common;</P>
      <P>import <A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>.<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>.*;<BR>import <A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>.lang.*;</P>
      <P>/**<BR>&* @author 李春雷<BR>&*<BR>&* TODO
      要更改此生成的类型注释的模板,请转至<BR>&* <A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>访问类<BR>&*/<BR>public class DbAccess<BR>{&
      <BR>&String strDBDriver = Constants.DBDRIVER;<BR>&String
      strDBUrl = Constants.DBUrl;<BR>&String username =
      Constants.USERNAME;<BR>&String password =
      Constants.PASSWORD;<BR>&private Connection conn =
      null;<BR>&private Statement stmt = null;<BR>&ResultSet
      rs=null;<BR>&//注册<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>驱动<A
      href="http://www.chinaitpower.com/Dev/index.html"
      target=_blank>程序</A><BR>&public DbAccess()<BR>&{&
      <BR>&&try <BR>&&{&
      <BR>&&&Class.forName(strDBDriver);<BR>&&}<BR>&&//异常处理<BR>&&catch(
      <A href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>.lang.ClassNotFoundException
      e)<BR>&&{<BR>&&&System.err.println("DbAccess():"+e.getMessage());<BR>&&}<BR>&}<BR>&//建立<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A>连接及定义数据查询<BR>&public ResultSet
      executeQuery(String <A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>)<BR>&{<BR>&&rs=null;<BR>&&try<BR>&&{<BR>&&&conn=DriverManager.getConnection(strDBUrl,username,password);<BR>&&&stmt=conn.createStatement();<BR>&&&rs=stmt.executeQuery(<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>);<BR>&&}<BR>&&catch(SQLException
      ex)<BR>&&{<BR>&&&System.err.println("ap.executeQuery:"+ex.getMessage());<BR>&&}<BR>&<BR>&&return
      rs;<BR>&}<BR>&//定义数据操库作<BR>&public void
      executeUpdate(String <A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>)<BR>&{<BR>&&stmt=null;<BR>&&rs=null;<BR>&&try<BR>&&{<BR>&&&conn=DriverManager.getConnection(strDBUrl,username,password);<BR>&&&stmt=conn.createStatement();<BR>&&&stmt.executeQuery(<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>);<BR>&&&stmt.close();<BR>&&&conn.close();<BR>&&}<BR>&&catch(SQLException
      ex)<BR>&&{<BR>&&&System.err.println("ap.executeQuery:"+ex.getMessage());<BR>&&}<BR>&}<BR>&//关闭<A
      href="http://www.chinaitpower.com/Dev/DataBase/index.html"
      target=_blank>数据库</A><BR>&public void
      closeStmt()<BR>&{<BR>&&try<BR>&&{<BR>&&&stmt.close();<BR>&&}<BR>&&catch(SQLException
      e)<BR>&&{<BR>&&&e.printStackTrace();<BR>&&}<BR>&}<BR>&public
      void
      closeConn()<BR>&{<BR>&&try<BR>&&{<BR>&&&conn.close();<BR>&&}<BR>&&catch(SQLException
      e)<BR>&&{<BR>&&&e.printStackTrace();<BR>&&}<BR>&}<BR>&public
      static void main(String[]
      args){<BR>&&System.out.println("hello,it's
      test");<BR>&&DbAccess dbaccess = new
      DbAccess();<BR>&&String <A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A> = "select * from xt_yh";<BR>&&ResultSet rs
      = dbaccess.executeQuery(<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>);<BR>&&try<BR>&&{<BR>&&&while(rs.next()){<BR>&&&&System.out.print(rs.getString(1)+rs.getString(2)+rs.getString(3)+rs.getString(4)+rs.getString(5)+rs.getString(6));<BR>&&&&System.out.println();<BR>&&&}<BR>&&dbaccess.closeStmt();<BR>&&dbaccess.closeConn();<BR>&&}
      <BR>&&catch (SQLException e)
      <BR>&&{<BR>&&&// TODO 自动生成 catch
      块<BR>&&&e.printStackTrace();<BR>&&}<BR>&}<BR>&}</P>
      <P>&/*********DepEmplConfig.jsp************/</P>
      <P>&&%@ page contentType="text/html; charset=gb2312" language="<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>" import="<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>.<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>.*,com.lcl.common.*" errorPage=""
      %&<BR>&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "<A
      href="http://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose.dtd</A>"&<BR>&html&<BR>&head&<BR>&meta
      http-equiv="Content-Type" content="text/html;
      charset=gb2312"&<BR>&title&无标题文档&/title&<BR>&HEAD&<BR>&script
      type="text/<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>script"
      src="../resources/xDataTree.js"&&/script&<BR>&link
      type="text/css" rel="stylesheet" href="../resources/xtree.css"
      /&<BR>&style type="text/css"&</P>
      <P>body
      {<BR>&background:&white;<BR>&color:&&black;<BR>}<BR>&/style&<BR>&TITLE&
      New Document &/TITLE&<BR>&META NAME="Generator"
      CONTENT="EditPlus"&<BR>&META NAME="Author"
      CONTENT=""&<BR>&META NAME="Keywords" CONTENT=""&<BR>&META
      NAME="Description" CONTENT=""&<BR>&/HEAD&<BR>&script
      type="text/<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>script"&&
      <BR>webFXTreeConfig.rootIcon&&=
      "../resources/images/xp/folder.png";<BR>webFXTreeConfig.openRootIcon&=
      "../resources/images/xp/openfolder.png";<BR>webFXTreeConfig.folderIcon&&=
      "../resources/images/xp/folder.png";<BR>webFXTreeConfig.openFolderIcon&=
      "../resources/images/xp/openfolder.png";<BR>webFXTreeConfig.fileIcon&&=
      "../resources/images/xp/file.png";<BR>webFXTreeConfig.lMinusIcon&&=
      "../resources/images/xp/Lminus.png";<BR>webFXTreeConfig.lPlusIcon&&=
      "../resources/images/xp/Lplus.png";<BR>webFXTreeConfig.tMinusIcon&&=
      "../resources/images/xp/Tminus.png";<BR>webFXTreeConfig.tPlusIcon&&=
      "../resources/images/xp/Tplus.png";<BR>webFXTreeConfig.iIcon&&&=
      "../resources/images/xp/I.png";<BR>webFXTreeConfig.lIcon&&&=
      "../resources/images/xp/L.png";<BR>webFXTreeConfig.tIcon&&&=
      "../resources/images/xp/T.png";<BR>webFXTreeConfig.blankIcon&&&&&&
      = "../resources/images/blank.png";</P>
      <P>var tree = new WebFXTree("单位人员基本情况","R0");<BR>var child;<BR>var
      nodeToAddPerson;</P>
      <P>function addDeptTreeNode(preNodeLevel,curNodeLevel,dispLabel,sKey,sTag)
      {<BR>& if(curNodeLevel==1) {<BR>&&&& child =
      tree.add(new WebFXTreeItem(dispLabel,sKey,sTag));<BR>& }<BR>&
      else {<BR>&&& if(curNodeLevel==preNodeLevel)
      {<BR>&&&&&&
      if(child.parentNode)<BR>&&&&&&& child =
      child.parentNode.add(new
      WebFXTreeItem(dispLabel,sKey,sTag));<BR>&&&
      }<BR>&&& if(curNodeLevel&preNodeLevel)
      {<BR>&&&&&& child = child.add(new
      WebFXTreeItem(dispLabel,sKey,sTag));<BR>&&&
      }<BR>&&& if(curNodeLevel&preNodeLevel)
      {<BR>&&&&&&&
      for(i=0;i&preNodeLevel-curNodeLevel+1;i++)
      <BR>&&&&&&&&&& child =
      child.parentNode;<BR>&&&&&&& child =
      child.add(new WebFXTreeItem(dispLabel,sKey,sTag));<BR>&&&
      }<BR>& }<BR>& return child;<BR>}</P>
      <P>function treeClick() {<BR>&if(tree.getSelected())
      {<BR>&&&&
      if(tree.getSelected().childNodes.length==0&&tree.getSelected().key!="R0")
      <BR>&&&&&& cmdDelete.disabled =
      false;<BR>&&&& else
      <BR>&&&&&& cmdDelete.disabled = true;
      <BR>&&&& if(tree.getSelected().key.substr(0,2)=="RZ")
      {<BR>&&&&&& cmdAddDept.disabled =
      true;<BR>&&&&&& cmdAddPeople.disabled =
      true;<BR>&&&&&& var
      strYhxh;<BR>&&&&&& strYhxh =
      tree.getSelected().key.substr(2);<BR>&&&&&&
      //window.open("../userAdm/editYh.do?yhxh="+strYhxh,"main");<BR>&&&&
      }<BR>&&&& else
      if(tree.getSelected().key.substr(0,2)=="RB")
      {<BR>&&&&&& cmdAddDept.disabled =
      false;<BR>&&&&&& cmdAddPeople.disabled =
      false;<BR>&&&&&& var
      strDwxh;<BR>&&&&&& strDwxh =
      tree.getSelected().key.substr(2);<BR>&&&&&&
      //window.open("../userAdm/editBm.do?dwxh="+strDwxh,"main");<BR>&&&&
      }<BR>&&&& else
      {<BR>&&&&&& cmdAddDept.disabled =
      false;<BR>&&&&&& cmdAddPeople.disabled =
      true;<BR>&&&&&&
      //window.open("yhroot.jsp","main");<BR>&&&&
      }<BR>&}<BR>}</P>
      <P>function addPeople() {<BR>&&& var
      strDwxh;<BR>&&& if(tree.getSelected()) {<BR>&& if
      (tree.getSelected().key.substr(0,2)=="RB")
      {<BR>&&&&&&& strDwxh =
      tree.getSelected().key.substr(2);<BR>&&//window.open("../userAdm/addYh.do?dwxh="+strDwxh,"main");<BR>&&alert("addPeople");<BR>&&
      }<BR>&&& }<BR>}</P>
      <P>function addDept() {<BR>&&& var
      strDwxh;<BR>&&& if(tree.getSelected()) {<BR>&& if
      (tree.getSelected().key.substr(0,2)=="RB")
      {<BR>&&&&&&& strDwfxh =
      tree.getSelected().key.substr(2);<BR>&&//window.open("../userAdm/addBm.do?dwfxh="+strDwfxh,"main");<BR>&&
      &alert("addDept");<BR>&&
      }<BR>&&&&& else if(tree.getSelected().key=="R0")
      {<BR>&&&&&&&
      //window.open("../userAdm/addBm.do?dwfxh=0","main");<BR>&&&&&&&
      alert("addDept");<BR>&&&&&
      }<BR>&&& }<BR>}</P>
      <P>function deleSelected() {<BR>&
      if(!confirm("确认删除该节点吗?"))<BR>&&&&&
      return;<BR>& if(tree.getSelected()) {<BR>&&&
      if(tree.getSelected().key.substr(0,2)=="RB")
      {<BR>&&&&&& var
      strDwxh;<BR>&&&&&& strDwxh =
      tree.getSelected().key.substr(2);<BR>&&&&&&
      //window.open("../userAdm/delBm.do?dwxh="+strDwxh,"main");<BR>&&&&&&
      alert("deleSelected");<BR>&&& }<BR>&&& else
      if(tree.getSelected().key.substr(0,2)=='RZ')
      {<BR>&&&&&& var
      strYhxh,strYhbh;<BR>&&&&&& strYhxh =
      tree.getSelected().key.substr(2);<BR>&&&&&&
      strYhbh = tree.getSelected().tag;<BR>&&&&&&
      //window.open("../userAdm/delYh.do?yhxh="+strYhxh+"&yhbh="+strYhbh,"main");<BR>&&&&&&
      alert("deleSelected");<BR>&&& }<BR>& }<BR>}</P>
      <P>function removeNode() {<BR>& if(tree.getSelected())
      {<BR>&&& var node =
      tree.getSelected();<BR>&&& node.remove();<BR>&
      }<BR>}</P>
      <P>function addPeopleNode(strParentKey,strKey,strText,strTag) {<BR>&
      if(tree.getSelected()) {<BR>&&& var node =
      tree.getSelected();<BR>&&& var
      childNode;<BR>&&& //node.expand();<BR>&&&
      childNode = node.add(new
      WebFXTreeItem(strText,strKey,strTag,"","","../resources/images/people1.png"));<BR>&&&
      node.expand(); //why I do so? I dont want to tell
      you,hah!<BR>&&& childNode.focus();<BR>&&&
      treeClick();<BR>& }<BR>}</P>
      <P>function addDeptNode(strParentKey,strKey,strText,strTag) {<BR>&
      if(tree.getSelected()) {<BR>&&& var node =
      tree.getSelected();<BR>&&& var
      childNode;<BR>&&& childNode = node.add(new
      WebFXTreeItem(strText,strKey,strTag));<BR>&&&
      node.expand();<BR>&&&
      childNode.focus();<BR>&&& treeClick();<BR>& }<BR>}</P>
      <P>function updateDeptNode(strTag,strText) {<BR>&
      if(tree.getSelected()) {<BR>&&& var node =
      tree.getSelected();<BR>&&& node.text =
      strText;<BR>&&& node.tag& =
      strTag;<BR>&&& node.focus();<BR>& }<BR>}</P>
      <P>function updatePeopleNode(strTag,strText) {<BR>&
      if(tree.getSelected()) {<BR>&&& var node =
      tree.getSelected();<BR>&&& node.text =
      strText;<BR>&&& node.tag& =
      strTag;<BR>&&& node.focus();<BR>&
      }<BR>}<BR>&/script&<BR>&%<BR>int dwxh;<BR>int dwfxh;<BR>int
      yhxh;<BR>String dwbh = null;<BR>String dwmc = null;<BR>String yhmc =
      null;<BR>String yhbh = null;<BR>int preLevel =1;<BR>int level =
      1;<BR>DbAccess dbaccess = new DbAccess();<BR>String <A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A> = "select dwxh,dwbh,dwmc,dwfxh from xt_dw order by
      dwbh";<BR>ResultSet rs = dbaccess.executeQuery(<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>);<BR>try<BR>{<BR>&while(rs.next())<BR>&{<BR>&&&&&&&
      dwxh = rs.getInt(1);<BR>&&&&&&& dwbh =
      rs.getString(2);<BR>&&&&&&& dwmc =
      rs.getString(3);<BR>&&&&&&& dwfxh =
      rs.getInt(4);<BR>//通过单位编号计算level<BR>&&String last =
      dwbh.substring(9,10);<BR>&&int i =
      9;<BR>&&while(last.equals("0") &&
      i&0){<BR>&&&i--;<BR>&&&last =
      dwbh.substring(i,i+1);<BR>&&<BR>&&}<BR>&&<BR>&&if(i==0
      || i==1) level =1;<BR>&&if(i==2 || i==3) level
      =2;<BR>&&if(i==4 || i==5) level =3;<BR>&&if(i==6 ||
      i==7) level =4;<BR>&&if(i==8 || i==9) level
      =5;<BR>//<BR>&&%&<BR>&&&&&&&&&&
      &script type="text/<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>script"&& <BR>&&&&
      nodeToAddPerson =
      addDeptTreeNode(&%=preLevel%&,&%=level%&,"&%=dwmc%&","RB&%=dwxh%&","&%=dwbh%&");<BR>&&&&&&&
      &/script&&&<BR>&&<BR>&&&%<BR>&&preLevel
      = level;<BR>&&String sub<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A> = "select yhxh,yhmc,yhbh from xt_yh where dwxh =
      "+Integer.toString(dwxh);<BR>&&ResultSet subRs =
      dbaccess.executeQuery(sub<A
      href="http://www.chinaitpower.com/Dev/DataBase/MsSql/index.html"
      target=_blank>sql</A>);<BR>&&&&&&
      while(subRs.next())
      {<BR>&&&&&&&&&&&&&
      yhxh =
      subRs.getInt(1);<BR>&&&&&&&&&&&&&
      yhmc =
      subRs.getString(2);<BR>&&&&&&&&&&&&&
      yhbh = subRs.getString(3);
      <BR>&&%&<BR>&&&&&&&&&&&&
      &script type="text/<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>script"&& <BR>&&&&
      nodeToAddPerson.add(new
      WebFXTreeItem("&%=yhmc%&","RZ&%=yhxh%&","&%=yhbh%&","","","../resources/images/people1.png"));<BR>&&&&&&&
      &/script&<BR>&&&&
      &%<BR>&&}<BR>&&<BR>&}<BR>&dbaccess.closeStmt();<BR>&dbaccess.closeConn();<BR>}<BR>catch(Exception
      e)<BR>{</P>
      <P>}<BR>%&</P>
      <P></P>
      <P>&base target="_self"&<BR>&META HTTP-EQUIV="PRAGMA"
      CONTENT="NO-CACHE"&<BR>&/head&<BR>&body&<BR>&table
      border="0" width="100%" cellspacing="0" cellpadding="0"&<BR>&
      &tr&<BR>&&& &td width="273"
      colspan="2"&<BR>&&&&&& &font face="宋体"
      size="3"&&&&&
      <BR>&&&&&&
      &/font&<BR>&&& &/td&<BR>&
      &/tr&<BR>& &tr&<BR>&&& &th width="33%"
      align="center" nowrap&<BR>&&&&& &p
      align="center"&<BR>&&&&& &INPUT
      id=cmdAddDept name="AddDept" type=button value="增加部门" onclick="addDept()"
      style="FONT-FAMILY: 楷体_GB2312; FONT-SIZE: 12pt; FONT-WEIGHT: bold; HEIGHT:
      24px; WIDTH: 80px" &<BR>&&&&&
      &/p&<BR>&&& &/th&<BR>&&& &th
      width="33%" align="center" nowrap&<BR>&&&&&
      &p align="center"&<BR>&&&&& &INPUT
      id=cmdAddPeople name="AddPeople" type=button value="增加用户"
      onclick="addPeople()" style="FONT-FAMILY: 楷体_GB2312; FONT-SIZE: 12pt;
      FONT-WEIGHT: bold; HEIGHT: 24px; WIDTH: 80px"
      &<BR>&&&&& &/p&<BR>&&&
      &/th&<BR>&&& &th width="33%" align="center"
      nowrap&<BR>&&&&& &p
      align="center"&<BR>&&&&& &INPUT
      id=cmdDelete name="Delete" type=button value=" 删除 "
      onclick="deleSelected()" style="FONT-FAMILY: 楷体_GB2312; FONT-SIZE: 12pt;
      FONT-WEIGHT: bold; HEIGHT: 24px; WIDTH: 80px"
      disabled&<BR>&&&&&
      &/p&<BR>&&& &/th&<BR>&
      &/tr&<BR>& &tr&<BR>&&& &td width="273"
      height="8"&
      colspan="2"& <BR>&&&&&
      <BR>&&& &/td&<BR>&
      &/tr&<BR>&/table&<BR>&/body&<BR>&div
      onclick="treeClick()"&<BR>&script type="text/<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>script"&&
      <BR>&document.write(tree);<BR>&/script&<BR>&/div&<BR>&/HTML&</P>
      <P>//其中jsp页面上的几个<A
      href="http://www.chinaitpower.com/Dev/Programme/Java/index.html"
      target=_blank>java</A>script函数为同事牛人彭越所写,我没改动,在此说明.<BR></P></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD class=p2 align=right bgColor=#fdf9e7 height=22><A
      href="http://duduwolf.360doc.com/showWeb/0/1/31209.aspx">上一篇</A>&&&&<A
      href="http://duduwolf.360doc.com/showWeb/0/1/30257.aspx">下一篇</A>&&&&(<A
      href="http://duduwolf.360doc.com/UserHome/677.aspx">smoking_boy</A>的分类目录[<A
      href="http://duduwolf.360doc.com/UserArt.aspx?UserID=677&CategoryID=1&GroupID=-1">我的图书馆</A>]*136篇)&&
    </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD class=p2 bgColor=#fffcf4>发表评论</TD></TR>
  <TR>
    <TD align=middle height=2></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD vAlign=top></TD>
    <TD vAlign=top>
      <FORM id=showWeb name=showWeb
      action=30580.aspx?Cream=0&CategoryID=0&ArticleID=30580
      method=post><INPUT type=hidden
      value=dDwtMTMzMjE3NjQ2Njt0PDtsPGk8MD47PjtsPHQ8QDA8cDxwPGw8RGF0YUtleXM7XyFJdGVtQ291bnQ7PjtsPGw8PjtpPDA+Oz4+Oz47Ozs7Ozs7Oz47Oz47Pj47PrMJmOXAYvkRKoedUaZNexdcdOy3
      name=__VIEWSTATE>
      <TABLE cellSpacing=0 cellPadding=0 width="90%" border=0>
        <TBODY>
        <TR>
          <TD class=p2 align=middle colSpan=2>游客请<A
            href="http://duduwolf.360doc.com/login.aspx?type=14&ArticleID=30580">登录</A>后再发表评论!
          </TD></TR></TBODY></TABLE></FORM></TD></TR></TBODY></TABLE></BODY></HTML>