梅花树的动态加载和同一父结点的子结点的交换位置.??
我用的是梅花雪大侠的MzTreeView 1.0 ,我是用jsp实现的,但怎么都显示不出一棵树来.,请问怎么实现梅花树的动态加载和同一父结点的子结点的交换位置.??
最好有代码?? 我的邮箱是dmh0203@163.com
我的代码如下:
页面代码:
<%@ page contentType= "text/html; charset=GBK " %>
<%@ page import= "tree.Treeview "%>
<%@ page import= "java.util.* "%>
<head>
</head>
<body>
<script language= "JavaScript " src= "d:/MzTreeView10/MzTreeView10.js "> </script>
<style>
A.MzTreeview
{
font-size: 9pt;
padding-left: 3px;
}
</style>
<script language= "JavaScript ">
var tree = new MzTreeView( "tree ");
tree.icons[ "property "] = "property.gif ";
tree.icons[ "css "] = "collection.gif ";
tree.icons[ "book "] = "book.gif ";
tree.iconsExpand[ "book "] = "bookopen.gif "; //展开时对应的图片
tree.setIconPath( "d://MzTreeView10// "); //可用相对路径
<%
Treeview treeview=new Treeview();
String node=treeview.getResultSet();
out.write(node);
%>
document.write(tree.toString());
</script>
</body>
</html>
bean的代码:
package tree;
import java.sql.*;
import java.util.*;
public class Treeview
{
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String url= "jdbc:mysql://localhost:3310/example?user=root&password=123 ";
public Treeview()
{
try
{
Class.forName( "org.gjt.mm.mysql.Driver ");
con=DriverManager.getConnection(url);
}catch(Exception e)
{
e.printStackTrace();
}
}
public String getResultSet()
{
String tree= " ";
try {
stmt = con.createStatement();
rs=stmt.executeQuery( "select * from tree ");
while (rs.next())
{
String id=rs.getString( "id ");
String parentId=rs.getString( "parentId ");
tree+= "\n "+ "tree.nodes[\ " "+id+ "_ "+parentId+ "\ "]=\ " ";
String text=rs.getString( "text ");
if(text!=null&&text.trim()!=( " "))
{
tree+= "text: "+text+ "; ";
}
String data=rs.getString( "data ");
if(data!=null&&data.trim()!=( " "))
{
tree+= "data:id= "+id+ "; ";
}
String hint=rs.getString( "hint ");
if(hint!=null&&hint.trim().equals( " ")==false)
{
tree+= "hint: "+hint+ "; ";
}
String icon=rs.getString( "icon ");
if(icon!=null&&icon.trim().equals( " ")==false)
{
tree+= "icon: "+icon+ "; ";
}
String url=rs.getString( "url ");
if(url!=null&&url.trim().equals( " ")==false)
{
tree+= "url: "+url+ "; ";
}
String target=rs.getString( "target ");
if(target!=null&&target.trim().equals( " ")==false)
{
tree+= "target: "+target+ "; ";
}
String method=rs.getString( "method ");
if(method!=null&&method.trim().equals( " ")==false)
{
tree+= "method: "+method+ "; ";
}
tree=tree.substring(0,tree.trim().length());
tree+= "\ "; ";
}
rs.close();
stmt.close();
}
catch (SQLException sql)
{
sql.printStackTrace();
}
return tree;
}
}
[解决办法]
帮顶,没找到一个梅花树jsp显示的实例啊!!
[解决办法]
去WEB开发 JAVASCRIPT区去找梅花雪去,他经常在那出现