/** * 将一个menu结点数据保存在库中 * * @param ele * @param parentId */ private void addMenu(Element ele, Integer parentId) { try { Menu menu = new Menu(); menu.setPid(parentId); String text = ele.getAttribute("text"); String url = ele.getAttribute("url"); String type = ele.getAttribute("type"); String selected = ele.getAttribute("selected"); String target = ele.getAttribute("target"); String mode = ele.getAttribute("mode"); if (type == null) { type = ((Element) ele.getParentNode()).getAttribute("type"); } if (target != null) { menu.setTarget(target); } int menuType = Menu.MENU_TYPE_APP; if ("sys".equals(type)) menuType = Menu.MENU_TYPE_SYS; if ("app".equals(type)) menuType = Menu.MENU_TYPE_APP; if ("ext".equals(type)) menuType = Menu.MENU_TYPE_EXT; menu.setMenutype(menuType); menu.setTitle(text); if ((selected != null) && (!selected.equals(""))) { menu.setSelected(Integer.valueOf(selected)); } if (url != null) menu.setUrl(url); menu.setSorder(50); if (mode != null) menu.setAppid(mode); Integer menuid = this.menuManager.add(menu); NodeList children = ele.getChildNodes(); if (children != null) { this.addMenu(children, menuid); } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("install menu error"); } }