Beispiel #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();
  }
Beispiel #2
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();
  }