xtree 的异步加载 XMLCacheCSS
程序员文章站
2022-03-02 16:56:25
...
其实呢,刚开始打算做的是静态的加载,但是,发现自己后台构建树的时间太长了,所以就放弃了,改成了异步加载,自己也是刚接触,看代码吧,很多都是copy的。
把xtree的文件夹放到项目中,然后再页面中引入js,css.
先见一个页面:
webFXTreeConfig.rootIcon = "<%=request.getContextPath()%>/xtree/images/folder.png";
webFXTreeConfig.openRootIcon = "<%=request.getContextPath()%>/xtree/images/openfolder.png";
webFXTreeConfig.folderIcon = "<%=request.getContextPath()%>/xtree/images/folder.png";
webFXTreeConfig.openFolderIcon = "<%=request.getContextPath()%>/xtree/images/openfolder.png";
webFXTreeConfig.fileIcon = "<%=request.getContextPath()%>/xtree/images/file.png";
webFXTreeConfig.lMinusIcon = "<%=request.getContextPath()%>/xtree/images/Lminus.png";
webFXTreeConfig.lPlusIcon = "<%=request.getContextPath()%>/xtree/images/Lplus.png";
webFXTreeConfig.tMinusIcon = "<%=request.getContextPath()%>/xtree/images/Tminus.png";
webFXTreeConfig.tPlusIcon = "<%=request.getContextPath()%>/xtree/images/Tplus.png";
webFXTreeConfig.iIcon = "<%=request.getContextPath()%>/xtree/images/I.png";
webFXTreeConfig.lIcon = "<%=request.getContextPath()%>/xtree/images/L.png";
webFXTreeConfig.tIcon = "<%=request.getContextPath()%>/xtree/images/T.png";
webFXTreeConfig.blankIcon = "<%=request.getContextPath()%>/xtree/images/blank.png";
var tree = new WebFXTree("XXXX");
tree.add(new WebFXLoadTreeItem("XXXXXX", "http://localhost:8080/servelt/..action"));//树的展开
document.write(tree);
然后去写一个action,里面只不过是构建了一个xml,构建xml的时候是什么插件都没有用,
在action中
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
PrintWriter out = response.getWriter();
然后就是构建xml,弄一个stringBuffer 一个一个的添加就行了,但是一定要设置
<xml>
<test src="跳转的action" action="展现的action" target=“展现action页面出现的位置”>
</test>
</xml>
然后
out.println(这个stringBuffer);
out.flush();
out.close();
这颗树就算构建完了,然后可以直接访问这个页面
简单的就算完事了。
把xtree的文件夹放到项目中,然后再页面中引入js,css.
先见一个页面:
webFXTreeConfig.rootIcon = "<%=request.getContextPath()%>/xtree/images/folder.png";
webFXTreeConfig.openRootIcon = "<%=request.getContextPath()%>/xtree/images/openfolder.png";
webFXTreeConfig.folderIcon = "<%=request.getContextPath()%>/xtree/images/folder.png";
webFXTreeConfig.openFolderIcon = "<%=request.getContextPath()%>/xtree/images/openfolder.png";
webFXTreeConfig.fileIcon = "<%=request.getContextPath()%>/xtree/images/file.png";
webFXTreeConfig.lMinusIcon = "<%=request.getContextPath()%>/xtree/images/Lminus.png";
webFXTreeConfig.lPlusIcon = "<%=request.getContextPath()%>/xtree/images/Lplus.png";
webFXTreeConfig.tMinusIcon = "<%=request.getContextPath()%>/xtree/images/Tminus.png";
webFXTreeConfig.tPlusIcon = "<%=request.getContextPath()%>/xtree/images/Tplus.png";
webFXTreeConfig.iIcon = "<%=request.getContextPath()%>/xtree/images/I.png";
webFXTreeConfig.lIcon = "<%=request.getContextPath()%>/xtree/images/L.png";
webFXTreeConfig.tIcon = "<%=request.getContextPath()%>/xtree/images/T.png";
webFXTreeConfig.blankIcon = "<%=request.getContextPath()%>/xtree/images/blank.png";
var tree = new WebFXTree("XXXX");
tree.add(new WebFXLoadTreeItem("XXXXXX", "http://localhost:8080/servelt/..action"));//树的展开
document.write(tree);
然后去写一个action,里面只不过是构建了一个xml,构建xml的时候是什么插件都没有用,
在action中
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
PrintWriter out = response.getWriter();
然后就是构建xml,弄一个stringBuffer 一个一个的添加就行了,但是一定要设置
<xml>
<test src="跳转的action" action="展现的action" target=“展现action页面出现的位置”>
</test>
</xml>
然后
out.println(这个stringBuffer);
out.flush();
out.close();
这颗树就算构建完了,然后可以直接访问这个页面
简单的就算完事了。