private static void addChildMenuItems( StringBuffer html, List<MenuItem> menuTree, String contextPath, boolean topLevel) { int topLevelCount = 0; for (MenuItem menuItem : menuTree) { Menu menu = menuItem.getMenu(); if (topLevel) { if (topLevelCount == 0) { html.append("\t<li id=\"nav-first\" >\n"); } else if (topLevelCount == menuTree.size() - 1) { html.append("\t<li id=\"nav-last\" >\n"); } else { html.append("\t<li>\n"); } topLevelCount++; } else { html.append("\t<li>\n"); } html.append("\t\t<a "); html.append("id=\""); html.append(menu.getElementId()); html.append("\" "); if (!GenericValidator.isBlankOrNull(menu.getLocalizedTooltip())) { html.append(" title=\""); html.append(menu.getLocalizedTooltip()); html.append("\" "); } if (menu.isOpenInNewWindow()) { html.append(" target=\"_blank\" "); } if (GenericValidator.isBlankOrNull(menu.getActionURL()) && GenericValidator.isBlankOrNull(menu.getClickAction())) { html.append(" class=\"no-link\" >"); } else { html.append(" href=\""); html.append(contextPath); html.append(menu.getActionURL()); html.append("\" >"); } html.append(menu.getLocalizedTitle()); html.append("</a>\n"); if (!menuItem.getChildMenus().isEmpty()) { html.append("<ul>\n"); addChildMenuItems(html, menuItem.getChildMenus(), contextPath, false); html.append("</ul>\n"); } html.append("\t</li>\n"); } }