Пример #1
0
  public String createTreeMenu(String navMenuName, boolean noAuth) throws Exception {
    NavMenu navMenu = this.navMenuService.getOneByName(navMenuName);
    if (navMenu == null) {
      navMenu = this.navMenuService.createDefaultNavMenu(navMenuName);
    }
    List<LiTag> topLiList = new ArrayList<LiTag>();
    LiTag topLi = new LiTag();
    ATag topA = new ATag();
    topA.setValue("全部菜单");
    topLi.setA(topA);

    List<LiTag> liList = new ArrayList<LiTag>();

    UlTag topUl = new UlTag();
    topUl.setClazz("");
    topUl.setLi(liList);
    topLi.setUl(topUl);

    topLiList.add(topLi);

    List<TreeMenu> parent = this.treeMenuService.getTopParent(navMenu.getNavMenuId());

    for (TreeMenu tm : parent) {
      if (tm.getTreeMenuId().longValue() == TreeMenuCons.TOP_TREE_MENU_ID()) {
        continue;
      }
      ATag a = new ATag();
      a.setValue(tm.getName());
      UlTag chidren = new UlTag("", createTree(tm.getTreeMenuId(), true));
      liList.add(new LiTag(a, chidren));
    }

    UlTag top = new UlTag(this.rootUlStyleClass, topLiList);

    return top.toString();
  }
Пример #2
0
  private List<LiTag> createTree(Long pid, boolean isCheckbox, boolean noAuth) throws Exception {
    List<LiTag> liList = new ArrayList<LiTag>();
    List<TreeMenu> children = this.treeMenuService.getChildren(pid);
    if (children == null) {
      return liList;
    }
    for (Iterator<TreeMenu> it = children.iterator(); it.hasNext(); ) {
      TreeMenu m = (TreeMenu) it.next();

      if ((!noAuth) && (findPerm(m.getTreeMenuId()).longValue() == -1L)) {
        continue;
      }
      if (isCheckbox) {
        ATag a = new ATag();
        if (this.treeMenuService.getChildren(m.getTreeMenuId()) == null) {
          a.setTname("treeMenuIds");
          a.setTvalue(m.getTreeMenuId());
        }

        a.setValue(m.getName());
        liList.add(new LiTag(a, new UlTag("", createTree(m.getTreeMenuId(), isCheckbox, noAuth))));
      } else {
        liList.add(
            new LiTag(
                new ATag(
                    null,
                    null,
                    false,
                    m.getTarget(),
                    m.getWidth() + "",
                    m.getHeight() + "",
                    m.getRel(),
                    m.getExternal(),
                    m.getReloadFlag(),
                    m.getHref(),
                    m.getName()),
                new UlTag("", createTree(m.getTreeMenuId(), isCheckbox, noAuth))));
      }
    }

    return liList;
  }
Пример #3
0
  public String createAllTreeMenu() throws Exception {
    List<NavMenu> navMenus = this.navMenuService.findAllOrderBy("rank", 1);
    if ((navMenus == null) || (navMenus.size() == 0)) {
      return "";
    }
    List<LiTag> topLiList = new ArrayList<LiTag>();
    LiTag topLi = new LiTag();
    ATag topA = new ATag();
    topA.setValue("全部菜单");
    topLi.setA(topA);

    List<LiTag> navLiList = new ArrayList<LiTag>();

    UlTag navUl = new UlTag();
    navUl.setClazz("");
    navUl.setLi(navLiList);
    topLi.setUl(navUl);

    topLiList.add(topLi);

    for (NavMenu navMenu : navMenus) {
      ATag navA = new ATag();
      LiTag navLi = new LiTag();
      navA.setValue(navMenu.getName());
      navLi.setA(navA);

      if ((navMenu.getHref().endsWith(".jsp")) || (navMenu.getHref().endsWith(".html"))) {
        navA.setTname("navMenuIds");
        navA.setTvalue(navMenu.getNavMenuId());
        navLiList.add(navLi);
        continue;
      }

      List<TreeMenu> parent = this.treeMenuService.getTopParent(navMenu.getNavMenuId());

      if ((parent == null) || (parent.size() == 1)) {
        continue;
      }
      List<LiTag> treeLiList = new ArrayList<LiTag>();

      UlTag treeUl = new UlTag();
      treeUl.setClazz("");
      treeUl.setLi(treeLiList);

      navLi.setUl(treeUl);

      for (TreeMenu tm : parent) {
        if (tm.getTreeMenuId().longValue() == TreeMenuCons.TOP_TREE_MENU_ID()) {
          continue;
        }
        ATag a = new ATag();
        a.setValue(tm.getName());

        treeLiList.add(new LiTag(a, new UlTag("", createTree(tm.getTreeMenuId(), true, true))));
      }

      if (treeLiList.size() > 0) {
        navLiList.add(navLi);
      }
    }

    UlTag top = new UlTag(this.rootUlStyleClass, topLiList);

    return top.toString();
  }