递归显示部门
2015-08-08 16:59
113 查看
<script>
function menuFoldClick(){
var srcE=window.event.srcElement;
var tagName=window.event.srcElement.tagName;
if(tagName=="LI"){
var nextBrother=srcE.nextSibling;
if(nextBrother.nodeType!=1){
nextBrother=nextBrother.nextSibling;
}
if(nextBrother.tagName=="UL"){
var displayCss=nextBrother.style.display;
if(displayCss=="none"){
nextBrother.style.display="";
}else{
nextBrother.style.display="none";
}
}
}
}
</script>
<ul onclick="menuFoldClick()">
<%HashMap depMap=(HashMap)request.getAttribute("depMap"); %>
<%!public void printSubDep(JspWriter out,HashMap depMap,Integer j,Integer id){
List list2=(List)depMap.get(j);
if(list2!=null&&list2.size()>0){
try{
boolean flag=false;
for(int n=0;n<list2.size();n++){
TDepartment dep2 =(TDepartment)list2.get(n);
if(dep2.getUpDep().intValue()==id.intValue()){
flag=true;
break;
}
}
if(flag) out.print("<ul>");
int k=j;
for(int n=0;n<list2.size();n++){
TDepartment dep2 =(TDepartment)list2.get(n);
if(dep2.getUpDep().intValue()==id.intValue()){
out.print("<li>" + dep2.getDepName()
+ "</li>");
j++;
printSubDep(out,depMap,j,dep2.getId());
}
j=k;
}
if(flag) out.print("</ul>");
}catch(IOException e){
e.getStackTrace();
}
}
} %>
<%
if (depMap.size()>0) {
List depListObj = (List) depMap.get(1);
for (int j = 0; j < depListObj.size(); j++) {
TDepartment dep = (TDepartment) depListObj.get(j);
out.print("<li>" + dep.getDepName() + "</li>");
printSubDep(out,depMap,2,dep.getId());
}
}
%>
</ul>
function menuFoldClick(){
var srcE=window.event.srcElement;
var tagName=window.event.srcElement.tagName;
if(tagName=="LI"){
var nextBrother=srcE.nextSibling;
if(nextBrother.nodeType!=1){
nextBrother=nextBrother.nextSibling;
}
if(nextBrother.tagName=="UL"){
var displayCss=nextBrother.style.display;
if(displayCss=="none"){
nextBrother.style.display="";
}else{
nextBrother.style.display="none";
}
}
}
}
</script>
<ul onclick="menuFoldClick()">
<%HashMap depMap=(HashMap)request.getAttribute("depMap"); %>
<%!public void printSubDep(JspWriter out,HashMap depMap,Integer j,Integer id){
List list2=(List)depMap.get(j);
if(list2!=null&&list2.size()>0){
try{
boolean flag=false;
for(int n=0;n<list2.size();n++){
TDepartment dep2 =(TDepartment)list2.get(n);
if(dep2.getUpDep().intValue()==id.intValue()){
flag=true;
break;
}
}
if(flag) out.print("<ul>");
int k=j;
for(int n=0;n<list2.size();n++){
TDepartment dep2 =(TDepartment)list2.get(n);
if(dep2.getUpDep().intValue()==id.intValue()){
out.print("<li>" + dep2.getDepName()
+ "</li>");
j++;
printSubDep(out,depMap,j,dep2.getId());
}
j=k;
}
if(flag) out.print("</ul>");
}catch(IOException e){
e.getStackTrace();
}
}
} %>
<%
if (depMap.size()>0) {
List depListObj = (List) depMap.get(1);
for (int j = 0; j < depListObj.size(); j++) {
TDepartment dep = (TDepartment) depListObj.get(j);
out.print("<li>" + dep.getDepName() + "</li>");
printSubDep(out,depMap,2,dep.getId());
}
}
%>
</ul>
相关文章推荐
- SVPullToRefresh深入理解
- BATCH_BACKUP
- MINIGUI学习总结一
- UVA 1395 Slim Span
- objective-c算法详解(一、链表)
- JavaScript学习笔记——对象分类
- 论文注解《Query Languages for Graph Databases》graph数据库查询语法(II)
- 13. ibatis最佳实践
- Atom飞行手册翻译: 4.5 ~ 4.8
- Ubuntu之Jenkins安装
- Hive 之表的种类以及相关操作
- adb opendir failed,Permission denied
- HM summary_01
- LintCode-带环链表 II
- UVA 340 Master-Mind Hints
- java 集合框架 泛型--15
- cocos2dx3.6实现打字效果
- [转]Windows 注册自定义的协议
- CSS hack样式兼容模式收藏
- codeforces 305E Playing with String