jsp网站开发四“酷”全书原码
源代码在线查看: menumanager.java
package com.publish.shop.taglib; import java.util.*; public class MenuManager{ public ArrayList initMenu(ArrayList listBaseMenu){ ArrayList list = new ArrayList(); if(listBaseMenu!=null && listBaseMenu.size()>0){ Menu tempMenu = null; for(int i=0;i tempMenu = (Menu)listBaseMenu.get(i); if(tempMenu.getMenuLevel()==1){ list.add(tempMenu); } if(tempMenu.getMenuLevel()==2){ Menu parentMenu = getMenu(tempMenu.getParentMenuID(),listBaseMenu); tempMenu.setParent(parentMenu); } if(tempMenu.getMenuLevel()==3){ Menu parentMenu = getMenu(tempMenu.getParentMenuID(),listBaseMenu); tempMenu.setParent(parentMenu); } } //init first list menu's action for(int i=0;i tempMenu = (Menu)list.get(i); List listSubMenu = tempMenu.getChilds(); Menu subMenu = null; Menu subSubMenu = null; for(int ii=0;ii subMenu = (Menu)listSubMenu.get(ii); if(subMenu!=null){ subSubMenu = subMenu.getChildAt(0); if(subSubMenu!=null) subMenu.setMenuLink(subSubMenu.getMenuLink()); } } subMenu = tempMenu.getChildAt(0); if(subMenu!=null){ tempMenu.setMenuLink(subMenu.getMenuLink()); } } } return list; } private Menu getMenu(String menuId,ArrayList listMenu){ Menu lMenu = null; Menu tempMenu = null; if(listMenu!=null && listMenu.size()>0){ for(int i=0;i tempMenu = (Menu)listMenu.get(i); if(menuId.equals(tempMenu.getMenuID())){ lMenu = tempMenu; return lMenu; } } } return lMenu; } }