Esempio n. 1
0
  public static void buildShopCatalogMenuStr(
      MenuItemView item, StringBuffer menuContent, int level) {
    if (item.getSubItems() != null && !item.getSubItems().isEmpty()) {
      Iterator it = item.getSubItems().iterator();
      String displayStatus = MenuItemView.DISPLAY_STATUS.OPEN;
      String ulClassName = null;

      while (it.hasNext()) {

        MenuItemView menuItem = (MenuItemView) it.next();
        String displayStatusChild = MenuItemView.DISPLAY_STATUS.OPEN;

        menuContent.append("  ");
        for (int i = 0; i < level; i++) {
          menuContent.append("&nbsp;&nbsp;");
        }

        if (menuItem.getSubItems() == null || menuItem.getSubItems().isEmpty()) {
          menuContent.append("<a "); // open 'a'
          menuContent.append(
              "href=\"javascript:  document.forms[0].elements['navigateCategoryId'].value='");
          menuContent.append(menuItem.getKey());
          menuContent.append("'; document.forms[0].submit();\" >");
        }
        menuContent.append(menuItem.getName());
        if (menuItem.getSubItems() == null || menuItem.getSubItems().isEmpty()) {
          menuContent.append("</a>");
        }
        menuContent.append("<br/>");

        buildShopCatalogMenuStr(menuItem, menuContent, (level + 1));
      }
    }
  }
Esempio n. 2
0
  public static void buildMenuStr(
      MenuItemView item, StringBuffer menuContent, String uid, int level) {
    if (item.getSubItems() != null && !item.getSubItems().isEmpty()) {
      Iterator it = item.getSubItems().iterator();
      level++;
      String displayStatus = item.getDisplayStatus();
      String ulClassName = null;
      if (MenuItemView.DISPLAY_STATUS.OPEN.equals(displayStatus)
          || Constants.ROOT.equals(item.getKey())) {
        ulClassName = "openelemBlocked";
      } else if (MenuItemView.DISPLAY_STATUS.CLOSE.equals(displayStatus)) {
        ulClassName = "closeelem";
      }

      menuContent.append("<");
      menuContent.append("table");
      menuContent.append(
          Utility.isSet(item.getKey()) ? " id=" + Utility.strNN(uid) + item.getKey() : "");
      menuContent.append(Utility.isSet(ulClassName) ? " class=" + ulClassName : "");
      menuContent.append(">");

      while (it.hasNext()) {

        MenuItemView menuItem = (MenuItemView) it.next();

        String displayStatusChild = menuItem.getDisplayStatus();
        String liClassName = null;
        if (MenuItemView.DISPLAY_STATUS.OPEN.equals(displayStatusChild)) {
          liClassName = "openliBlocked";
        } else if (MenuItemView.DISPLAY_STATUS.CLOSE.equals(displayStatus)) {
          liClassName = "closeli";
        }

        menuContent.append("<"); // open 'li'
        menuContent.append("tr");
        menuContent.append(
            Utility.isSet(menuItem.getKey())
                ? " id=child" + Utility.strNN(uid) + menuItem.getKey()
                : "");
        menuContent.append(Utility.isSet(liClassName) ? " class=" + liClassName : "");
        menuContent.append(">"); // close 'li'
        menuContent.append("<td>");
        menuContent.append("<"); // open 'a'
        menuContent.append("a class=\"categorymenulevel_");
        menuContent.append(level > 3 ? 3 : level);
        menuContent.append(
            MenuItemView.DISPLAY_STATUS.OPEN.equals(displayStatusChild) ? "_block" : "");
        menuContent.append("\"");
        if (menuItem.getSubItems() != null && !menuItem.getSubItems().isEmpty()) {
          menuContent.append(
              Utility.isSet(menuItem.getKey())
                  ? " href=\""
                      + (Utility.isSet(menuItem.getLink()) ? menuItem.getLink() : "#")
                      + "\" onMouseOver=\"javascript:openTreeLevel("
                      + "child"
                      + Utility.strNN(uid)
                      + menuItem.getKey()
                      + ","
                      + Utility.strNN(uid)
                      + menuItem.getKey()
                      + ","
                      + Utility.strNN(uid)
                      + item.getKey()
                      + ")\""
                      + " onMouseOut=\"javascript:closeTreeLevel("
                      + "child"
                      + Utility.strNN(uid)
                      + menuItem.getKey()
                      + ","
                      + Utility.strNN(uid)
                      + menuItem.getKey()
                      + ","
                      + Utility.strNN(uid)
                      + item.getKey()
                      + ")\""
                  : "");
        } else {
          menuContent.append(
              Utility.isSet(menuItem.getKey())
                  ? " href=\""
                      + (Utility.isSet(menuItem.getLink()) ? menuItem.getLink() : "#")
                      + "\" onMouseOver=\"javascript:openItem("
                      + "child"
                      + Utility.strNN(uid)
                      + menuItem.getKey()
                      + ","
                      + Utility.strNN(uid)
                      + item.getKey()
                      + ")\""
                      + " onMouseOut=\"javascript:closeItem("
                      + "child"
                      + Utility.strNN(uid)
                      + menuItem.getKey()
                      + ","
                      + Utility.strNN(uid)
                      + item.getKey()
                      + ")\""
                  : "");
        }
        menuContent.append(">"); // close 'a'

        menuContent.append(menuItem.getName());

        menuContent.append("</a>");

        buildMenuStr(menuItem, menuContent, uid, level);

        menuContent.append("</td>");
        menuContent.append("</tr>");
      }
      menuContent.append("</table>");
    }
  }