资源简介

学习TreePanel时根据网上的资料自己实现的实例,结构如下: 1. 创建一棵树 2. 使用TreeLoader加载数据生成树 3. 读取本地Json数据生成树 4. 使用Servlet提供数据 5. 树的事件 6. 右键菜单 7. 修改节点的默认图标 8. 给节点增加提示信息 9. 为节点设置超链接 10. 编辑节点名称 11. 树形的拖放 12. 判断拖放目标 13. 树之间的拖放 14. 过滤器 15. 对树进行排序 16. 对树增加复选框 代码中有详尽的注释。

资源截图

代码片段和文件信息

package com.magus.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CheckedAction extends HttpServlet{

private static final long serialVersionUID = 1L;

public CheckedAction() {

}

protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
doPost(request response);
}

protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
System.out.println(“Tree---------------请求到来!“);
request.setCharacterEncoding(“utf-8“);
response.setCharacterEncoding(“utf-8“);

// 获取单击的节点id
String node = request.getParameter(“node“);
System.out.println(“获取的节点ID: “ + node);
String json = ““;

if(“0“.equals(node)) { // 全部分组
json += “[{id:‘1‘ checked: false text: ‘我的好友‘} {id:‘2‘ checked: false text: ‘我的同学‘}{id:‘3‘ checked: false text: ‘陌生人‘ leaf: true}]“;
} else if(“1“.equals(node)) {
json += “[{id:‘11‘ checked: false text: ‘张三‘ leaf: true} {id:‘12‘ checked: false text: ‘李四‘ leaf: true} {id:‘13‘ checked: false text: ‘王五‘ leaf: true}]“;
} else if(“2“.equals(node)) {
json += “[{id:‘21‘ checked: false text: ‘刘备‘ leaf: true} {id:‘22‘ checked: false text: ‘曹操‘ leaf: true} {id:‘23‘ checked: false text: ‘孙尚香‘ leaf: true}]“;
}

System.out.println(“返回数据: “ + json);
response.getWriter().write(json);
System.out.println(“Tree---------------请求结束!“);
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-03-18 13:47  Ext_Tree\
     文件         841  2014-03-18 13:48  Ext_Tree\.classpath
     文件        1041  2014-03-18 13:48  Ext_Tree\.project
     目录           0  2014-03-18 13:48  Ext_Tree\.settings\
     文件         503  2014-03-18 13:48  Ext_Tree\.settings\.jsdtscope
     文件         364  2014-03-18 13:47  Ext_Tree\.settings\org.eclipse.jdt.core.prefs
     文件         478  2014-03-18 13:48  Ext_Tree\.settings\org.eclipse.wst.common.component
     文件         345  2014-03-18 13:48  Ext_Tree\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2014-03-18 13:48  Ext_Tree\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2014-03-18 13:48  Ext_Tree\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2014-03-20 01:16  Ext_Tree\WebContent\
     目录           0  2014-03-18 13:48  Ext_Tree\WebContent\meta-INF\
     文件          39  2014-03-18 13:48  Ext_Tree\WebContent\meta-INF\MANIFEST.MF
     目录           0  2014-03-19 21:39  Ext_Tree\WebContent\WEB-INF\
     目录           0  2014-04-04 09:21  Ext_Tree\WebContent\WEB-INF\lib\
     文件        1995  2014-03-22 13:23  Ext_Tree\WebContent\WEB-INF\web.xml
     目录           0  2014-03-22 11:54  Ext_Tree\WebContent\data\
     文件        1482  2014-03-19 20:08  Ext_Tree\WebContent\data\asyncTreeNode.txt
     文件        1000  2014-03-22 12:03  Ext_Tree\WebContent\data\drag.txt
     文件        1000  2014-03-22 12:04  Ext_Tree\WebContent\data\drop.txt
     目录           0  2014-03-18 13:48  Ext_Tree\WebContent\ext3\
     文件     1460259  2013-10-08 14:48  Ext_Tree\WebContent\ext3\ext-all.js
     文件       97308  2013-10-08 14:48  Ext_Tree\WebContent\ext3\ext-base.js
     文件       62868  2013-10-08 14:48  Ext_Tree\WebContent\ext3\ext-jquery-adapter.js
     文件        7800  2013-10-08 14:48  Ext_Tree\WebContent\ext3\ext-lang-zh_CN.js
     目录           0  2014-03-18 13:48  Ext_Tree\WebContent\ext3\resources\
     目录           0  2014-03-18 13:48  Ext_Tree\WebContent\ext3\resources\css\
     文件      139591  2013-10-08 14:48  Ext_Tree\WebContent\ext3\resources\css\ext-all.css
     目录           0  2014-03-18 13:48  Ext_Tree\WebContent\ext3\resources\images\
     目录           0  2014-03-18 13:48  Ext_Tree\WebContent\ext3\resources\images\default\
     目录           0  2014-03-18 13:48  Ext_Tree\WebContent\ext3\resources\images\default\box\
............此处省略508个文件信息

评论

共有 条评论