动态json-tree
来源:互联网 发布:php选课系统源码 编辑:程序博客网 时间:2024/06/06 05:08
// 动态构造tree
public List<TreeVO> insertTree(String path) {
LinkedList<NamedNodeMap> folderList = new LinkedList();
LinkedList<NamedNodeMap> fileList = new LinkedList();
folderList = getfolderlist(path);// 传个路径,查出该路径下的所有文件夹
fileList = getfilelist(path);// 传个路径,查出该路径下的所有文件夹
folderList.addAll(fileList);// 文件夹+文件
List<TreeVO> lt = new ArrayList<TreeVO>();// 用来存放动态树的集合
for (NamedNodeMap namedNodeMap : folderList) {
String folderName = namedNodeMap.getNamedItem("label").getNodeValue();
String fpath = namedNodeMap.getNamedItem("path").getNodeValue();
String type = namedNodeMap.getNamedItem("type").getNodeValue();
TreeVO tv = new TreeVO();
tv.setId(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
tv.setText(folderName);
tv.setAttributes("{\"url\":\"/Portal/jqueryEasyUi/html/data.html\"}");
tv.setPath(fpath);
if ("folder".equalsIgnoreCase(type)) {
tv.setIconCls("icon-tree-folder");
tv.setChildren(insertTree(fpath)); // 递归 (从外往里)
}
lt.add(tv);
}
return lt;
}
// 写个方法,把最后的tree给转成json字符串
public String getJsonString(String path) {
List<TreeVO> lt = this.insertTree(path);
JSONArray ja = JSONArray.fromCollection(lt);
String js = ja.toString();
return js;
}
//TreeVO类
/**
*
* @author hou
*/
public class TreeVO {
private String id;
private String text;
private String attributes;
private String iconCls;
private String path;
private List<TreeVO> children;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getIconCls() {
return iconCls;
}
public void setIconCls(String iconCls) {
this.iconCls = iconCls;
}
public String getAttributes() {
return attributes;
}
public void setAttributes(String attributes) {
this.attributes = attributes;
}
public List<TreeVO> getChildren() {
return children;
}
public void setChildren(List<TreeVO> children) {
this.children = children;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
- 动态json-tree
- ext 动态tree json算法
- jquery easyui tree动态加载-服务端struts返回json数据
- asp.net返回json 动态生成jQuery Easyui tree
- extjs的tree的使用(拖动、动态载入json数据、拖动后的事件处理)
- extjs的tree的使用(拖动、动态载入json数据、拖动后的事件处理)
- ExtJS4+Servlet/Struts2+JSON+accordion布局动态Ext.tree.Panel菜单
- ExtJS4+Servlet/Struts2+JSON+accordion布局动态Ext.tree.Panel菜单
- 后台如何拼接easyUI tree格式的 json数据 构建动态树
- Extjs Tree + JSON + Struts2
- extjs4 tree struts2 json
- extjs json tree
- extjs4 tree oracle json
- JSON转化为Tree
- extjs Tree转json
- bootstrap tree及json
- 动态创建Tree
- 动态的tree ajax
- MFC六大关键技术之(三)——动态创建
- JVM Crash
- 当春天泛滥的时候----<李春天的春天>的影评
- SAP电子数据交换EDI
- IE9梦幻任务栏pin计划 - 简单实用
- 动态json-tree
- 在Win7下用VisualBox安装ubuntu
- js 对象创建
- moss2010 事件处理
- Ubuntu 10.04 下 Wine 完美安装 QQ2010 正式版
- 第一个GTK+程序
- android 地图服务开发 INSTALL_FAILED_MISSING_SHARED_LIBRARY 错误解决
- PHP编程之HTML(表单的使用)
- 2011-06-08~2011-07-28 阶段总结