oletree问题请教

shetianlang 2011-03-02 07:20:52
大家好,我的问题是:利用oletree来从数据库中生成动态的四层的一个树.

目前的困难是只写两层则完全正常,到第三层就乱显示了,请教各位.
代码如下:
三层树的代码:
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page language="java"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.SQLException"%>
<%@ page import="com.crm.dao.XConnection"%>
<%@ page import="com.oletech.html.tree.OleTreeNode" %>
<%@ page import="com.oletech.html.tree.OleTreeMenu" %>
<%@ page import="com.crm.ui.CrmContant" %>
<html>
<head>
<title>区域列表树</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="./dtree.css">
<style type="text/css">
<!--
body {
background-color: #e7edf4;
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
</head>
<%
String background_color = "B5DBDE";
OleTreeMenu tmInfo = new OleTreeMenu("tmInfo");
tmInfo.setJsDir("./javascript/");
tmInfo.printHeader(out);
OleTreeNode tn = new OleTreeNode("d");
tn.setJsDir("./javascript/");
tn.setImgDir("./treeimages/");
tn.setBgColor("#"+background_color);
tn.setColorMouseOnBG("bisque");
out.println(tn.getClickScriptFunction());
out.println(tn.getColorScript());

String nextSrc = "CustIndex.jsp";
String nextName = "content";

Connection conn = null;
PreparedStatement OneLevel = null;
PreparedStatement TwoLevel = null;
PreparedStatement ThrLevel = null;
ResultSet oRs1 = null;
ResultSet oRs2 = null;
ResultSet oRs3 = null;
String strUrl = "";

%>
<body bgcolor="#<%=background_color%>">
<div style='height:450;text-overflow:ellipsis;overflow: auto;'>
<%
out.write("<fieldset>");
try{
XConnection connection = new XConnection();
conn = connection.getConnection();
conn.setAutoCommit(false);
OneLevel = conn.prepareStatement("SELECT id,name FROM crm_district WHERE level=1 AND up_level=0");
oRs1 = OneLevel.executeQuery();
int i = 0;
int vdistid1= 0;
String vdistname1 = "";
while (oRs1.next()){
i++;
vdistid1 = oRs1.getInt("id");
byte []bs1 = oRs1.getBytes("name");
if(bs1!=null){
vdistname1 = new String(bs1);
if(vdistname1==null||vdistname1.trim().equalsIgnoreCase("null")) vdistname1="";
}
OleTreeNode tnOne = new OleTreeNode(""+i,vdistname1);
tnOne.setImgDir("./treeimages/");
tnOne.addLink(nextSrc+"?"+ strUrl +"&districtid="+vdistid1,nextName);
tnOne.setIsClosed(true);

TwoLevel = conn.prepareStatement("SELECT id,name FROM crm_district WHERE level=2 AND up_level=?");
TwoLevel.setInt(1,vdistid1);
oRs2 = TwoLevel.executeQuery();
int j = 100;
int vdistid2 =0;
String vdistname2 = "";
while (oRs2.next()){
j++;
vdistid2 = oRs2.getInt("id");
byte []bs2 = oRs2.getBytes("name");
if(bs2!=null){
vdistname2 = new String(bs2);
if(vdistname2==null||vdistname2.trim().equalsIgnoreCase("null")) vdistname2="";
}
OleTreeNode tnTwo = new OleTreeNode("" + i + j,vdistname2);
tnTwo.setImgDir("./treeimages/");
tnOne.addChild(tnTwo);
tnTwo.addLink(nextSrc+"?"+strUrl+"&districtid="+vdistid2,nextName);
tnTwo.setIsClosed(true);
//-------------------------第三层代码---------------
ThrLevel = conn.prepareStatement("SELECT id,name FROM crm_district WHERE level=3 AND up_level=?");
ThrLevel.setInt(1,vdistid2);
oRs3 = ThrLevel.executeQuery();
int k = 1000;
int vdistid3 =0;
String vdistname3 = "";
while (oRs3.next()){
k++;
vdistid3 = oRs3.getInt("id");
byte []bs3 = oRs3.getBytes("name");
if(bs3!=null){
vdistname3 = new String(bs3);
if(vdistname3==null||vdistname3.trim().equalsIgnoreCase("null")) vdistname3="";
}
OleTreeNode tnThr = new OleTreeNode("" + i + j + k,vdistname3);
tnThr.setImgDir("./treeimages/");
tnTwo.addChild(tnThr);
tnThr.addLink(nextSrc+"?"+strUrl+"&districtid="+vdistid3,nextName);
tnThr.setIsClosed(true);
}
tnTwo.printTree2(out);
oRs3.close();
ThrLevel.close();
//----------------------------------------------------------------
}
tnOne.printTree2(out);
oRs2.close();
TwoLevel.close();
}
oRs1.close();
conn.commit();
OneLevel.close();
conn.close();
}catch (Exception ex){
conn.close();
ex.printStackTrace();
}
out.println("</fieldset>");
%>
</div>
</body>
</html>
红色字体为加第三层的代码.不加红色代码则两层树完全正常.贴图如下:




请问怎么解决啊?
...全文
27 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
shetianlang 2011-03-03
哎,没人给我指点一下
回复
shetianlang 2011-03-03
请各位高手帮我看看啊,跪谢了
回复
shetianlang 2011-03-02
囧了,图片怎么显示不了,大家去这里看下,谢谢

http://hi.csdn.net/space-1516995-do-album-picid-753516-goto-down.html
http://hi.csdn.net/space-1516995-do-album-picid-753517-goto-down.html
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2011-03-02 07:20
社区公告
暂无公告