[英]Java JSP custom tag for nested tree structure.
I want to create my custom Java JSP tags for tree structure such as: 我想为树结构创建自定义Java JSP标记,例如:
<ul>
<li>
<a href="#">Root</a>
<ul>
<li><a href="#">Node</a></li>
<li><a href="#">Node</a></li>
<li><a href="#">Node</a></li>
<li>
<a href="#">Node</a>
<ul>
<li><a href="#">Node</a></li>
<li><a href="#">Node</a></li>
</ul>
</li>
</ul>
</li>
</ul>
In JSP file an XML should looks like: 在JSP文件中,XML应该如下所示:
<lib:treeview>
<lib:treenode path="/some/path.do" label="Root">
<lib:treenode path="/some/path.do" label="NodeLabel"/>
<lib:treenode path="/some/path.do" label="NodeLabel"/>
<lib:treenode path="/some/path.do" label="NodeLabel"/>
</lib:node>
</lib:treeview>
Did somebody implement nested structures like this one? 是否有人实现了像这样的嵌套结构? What classes are better to use?
最好使用哪些类? Maybe somebody has some useful links?
也许有人有一些有用的链接? Help, please :)
请帮助 :)
Haven't tested this, something like this should work: 尚未测试过,类似这样的东西应该可以工作:
treeview.tag: treeview.tag:
<%@ tag description="treeview" %>
<ul>
<jsp:doBody />
</ul>
treenode.tag: treenode.tag:
<%@ tag description="treenode" %>
<%@ attribute name="label" required="true" type="java.lang.String" %>
<%@ attribute name="path" required="true" type="java.lang.String" %>
<li>
<a href="${path}">${label}</a>
<jsp:doBody />
</li>
test.jsp: test.jsp:
<lib:treeview>
<lib:treenode label="root" path="#">
<lib:treeview>
<lib:treenode label="node" path="#">
<lib:treenode label="node" path="#">
<lib:treenode label="node" path="#">
</lib:treeview>
</lib:treenode>
</lib:treeview>
output: 输出:
<ul>
<li>
<a href="#">root</a>
<ul>
<a href="#">node</a>
<a href="#">node</a>
<a href="#">node</a>
</ul>
</li>
</ul>
This JSP tree is simple one. 这个JSP树很简单。 You can enhance.
您可以增强。 It has checkboxes as well.
它还具有复选框。 The complete source code and Read Me file will guide you.
完整的源代码和自述文件将指导您。 I have wrote this in my free time.
我是在业余时间写的。 Bye
再见
http://sourceforge.net/projects/jsptree-simple/ http://sourceforge.net/projects/jsptree-simple/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.