XloadTree是http://webfx.eae.net/公司的基于JavaScript的建立树型目录的开源产品,扩展性强,使用简单。
1。XloadTree是基于XmlHttp请求/响应模型,必须使用http协议访问代码才可以正确加载XML文件。
2。使用JSP/Servlet的实例如下:
tree.jsp
修改代码:
1。XloadTree是基于XmlHttp请求/响应模型,必须使用http协议访问代码才可以正确加载XML文件。
2。使用JSP/Servlet的实例如下:
tree.jsp
<%@ page
language="java"
contentType="text/xml; charset=UTF-8"
pageEncoding="UTF-8"
%>
<%
response.setContentType("text/xml");
out.println("<tree>");
out.println("<tree text=\"Load tree1.xml\" src=\"tree1.xml\" />");
out.println("<tree text=\"Loaded Item 1\" action=\"http://webfx.eae.net\" />");
out.println("<tree text=\"Loaded Item 2\">");
out.println("<tree text=\"Loaded Item 2.1\" action=\"javascript:alert(2.1)\" />");
out.println("</tree>");
out.println("<tree text=\"Loaded Item 3 (with target)\" action=\"http://www.google.com\" target=\"_new\" />");
out.println("<tree text=\"Load tree.xml\" src=\"tree.xml\" />");
out.println("</tree>");
%>
注意contentType="text/xml; charset=UTF-8" 和response.setContentType("text/xml"),使用的是"text/xml"不是"text/html"。language="java"
contentType="text/xml; charset=UTF-8"
pageEncoding="UTF-8"
%>
<%
response.setContentType("text/xml");
out.println("<tree>");
out.println("<tree text=\"Load tree1.xml\" src=\"tree1.xml\" />");
out.println("<tree text=\"Loaded Item 1\" action=\"http://webfx.eae.net\" />");
out.println("<tree text=\"Loaded Item 2\">");
out.println("<tree text=\"Loaded Item 2.1\" action=\"javascript:alert(2.1)\" />");
out.println("</tree>");
out.println("<tree text=\"Loaded Item 3 (with target)\" action=\"http://www.google.com\" target=\"_new\" />");
out.println("<tree text=\"Load tree.xml\" src=\"tree.xml\" />");
out.println("</tree>");
%>
修改代码:
<script type="text/javascript">
/// XP Look
webFXTreeConfig.rootIcon = "images/xp/folder.png";
webFXTreeConfig.openRootIcon = "images/xp/openfolder.png";
webFXTreeConfig.folderIcon = "images/xp/folder.png";
webFXTreeConfig.openFolderIcon = "images/xp/openfolder.png";
webFXTreeConfig.fileIcon = "images/xp/file.png";
webFXTreeConfig.lMinusIcon = "images/xp/Lminus.png";
webFXTreeConfig.lPlusIcon = "images/xp/Lplus.png";
webFXTreeConfig.tMinusIcon = "images/xp/Tminus.png";
webFXTreeConfig.tPlusIcon = "images/xp/Tplus.png";
webFXTreeConfig.iIcon = "images/xp/I.png";
webFXTreeConfig.lIcon = "images/xp/L.png";
webFXTreeConfig.tIcon = "images/xp/T.png";
//var tree = new WebFXLoadTree("WebFXLoadTree", "tree1.xml");
//tree.setBehavior("classic");
var rti;
var tree = new WebFXTree("Root");
tree.add(new WebFXTreeItem("Tree Item 1"));
tree.add(new WebFXLoadTreeItem("Tree Item 2", "tree.jsp"));//Loading JSP File
tree.add(rti = new WebFXLoadTreeItem("Tree Item 3 (Reload)", "date.xml.pl"));
tree.add(new WebFXTreeItem("Tree Item 4"));
document.write(tree);
</script>
/// XP Look
webFXTreeConfig.rootIcon = "images/xp/folder.png";
webFXTreeConfig.openRootIcon = "images/xp/openfolder.png";
webFXTreeConfig.folderIcon = "images/xp/folder.png";
webFXTreeConfig.openFolderIcon = "images/xp/openfolder.png";
webFXTreeConfig.fileIcon = "images/xp/file.png";
webFXTreeConfig.lMinusIcon = "images/xp/Lminus.png";
webFXTreeConfig.lPlusIcon = "images/xp/Lplus.png";
webFXTreeConfig.tMinusIcon = "images/xp/Tminus.png";
webFXTreeConfig.tPlusIcon = "images/xp/Tplus.png";
webFXTreeConfig.iIcon = "images/xp/I.png";
webFXTreeConfig.lIcon = "images/xp/L.png";
webFXTreeConfig.tIcon = "images/xp/T.png";
//var tree = new WebFXLoadTree("WebFXLoadTree", "tree1.xml");
//tree.setBehavior("classic");
var rti;
var tree = new WebFXTree("Root");
tree.add(new WebFXTreeItem("Tree Item 1"));
tree.add(new WebFXLoadTreeItem("Tree Item 2", "tree.jsp"));//Loading JSP File
tree.add(rti = new WebFXLoadTreeItem("Tree Item 3 (Reload)", "date.xml.pl"));
tree.add(new WebFXTreeItem("Tree Item 4"));
document.write(tree);
</script>