日期:2014-05-16 浏览次数:20550 次
tree_menu_id | tree_menu_text | tree_menu_pid | tree_menu_action |
1 | 系统设置 | 0 | null |
2 | 用户设置 | 1 | user_action |
3 | 角色设置 | 1 | role_action |
4 | 权限设置 | 1 | privilege_action |
5 | 业务模块 | 0 | null |
6 | 销售管理 | 5 | sale_action |
package com.project.layout.treemenu; import java.util.*; import com.bsm.user.User; public class TreeMenu { private String treeMenuId; private String treeMenuPid; private String treeMenuText; private String treeMenuAction; private List children = new ArrayList(); public TreeMenu(String treeMenuId, String treeMenuPid,String treeMenuText,String treeMenuAction, ArrayList children) { this.treeMenuId = treeMenuId; this.treeMenuPid = treeMenuPid; this.treeMenuText = treeMenuText; this.treeMenuAction = treeMenuAction; this.children = children; } public String getTreeMenuAction() { return treeMenuAction; } public void setTreeMenuAction(String treeMenuAction) { this.treeMenuAction = treeMenuAction; } public TreeMenu() { } public String getTreeMenuId() { return treeMenuId; } public void setTreeMenuId(String treeMenuId) { this.treeMenuId = treeMenuId; } public String getTreeMenuPid() { return treeMenuPid; } public void setTreeMenuPid(String treeMenuPid) { this.treeMenuPid = treeMenuPid; } public String getTreeMenuText() { return treeMenuText; } public void setTreeMenuText(String treeMenuText) { this.treeMenuText = treeMenuText; } public List getChildren() { return children; } public void setChildren(List children) { this.children = children; } }
package com.project.layout.treemenu; import java.util.ArrayList; import java.util.List; public class TreeMenuDAO { public List getTreeMenuList() { String sql = "SELECT TREE_MENU_ID , TREE_MENU_TEXT , TREE_MENU_PID , TREE_MENU_ACTION FROM TREE_MENU_T ORDER BY TREE_MENU_PID,TREE_MENU_ID;"; list = new ArrayList(); //具体取语句就不多说了,因为关于从表中取得数据的实例太多了,各个人又个人的不同实现方法 treeMenu = new TreeMenu(); treeMenu.setTreeMenuId(s[i][j++]); treeMenu.setTreeMenuText(s[i][j++]); treeMenu.setTreeMenuPid(s[i][j++]); treeMenu.setTreeMenuAction(s[i][j++]); list.add(treeMenu); return list;//返回list对象 } }
package com.project.layout.treemenu; import com.bsm.user.User; import java.util.List; import java.util.ArrayList; public class TreeMenuBO { private TreeMenu tm = new TreeMenu(); private List tList = new ArrayList(); public List getTreeViewList() { TreeMenu treeMenu = new TreeMenu(); TreeMenuDAO dao = new TreeMenuDAO(); List list = dao.getTreeMenuList(); this.tm = new TreeMenu("0", "0", "root", "", new ArrayList());// 设置顶级元素,为了便于子list的挂载,在返回时候,去掉 tList.add(tm); for (int i = 0; i < list.size(); i++) { this.tm = (TreeMenu) li