static void addMenuComponent(final PageParameter pp) { final MenuBean menu = (MenuBean) pp.addComponentBean("AbstractHeaderPage_menu", MenuBean.class) .setMenuEvent(EMenuEvent.mouseenter) .setSelector(".re .acts .link_menuicon"); final AbstractElement<?>[] eles = new AbstractElement[] { ModuleContextFactory.get(IMyPortalWebContext.class).toMyPortalElement(pp), ModuleContextFactory.get(IFavoriteWebContext.class).toMyFavoriteElement(pp) }; for (final AbstractElement<?> ele : eles) { if (ele instanceof LinkElement) { final LinkElement link = (LinkElement) ele; if ("-".equals(link.getText())) { menu.addItem(MenuItem.sep()); } else { menu.addItem(MenuItem.of(link.getText()).setUrl(link.getHref())); } } } menu.addItem(MenuItem.sep()); menu.addItem( MenuItem.of($m("DemoTemplateT1.0")).setUrl(AbstractMVCPage.url(UserAttriPageT2.class))); }
@Override public MenuItems getMainMenuItems( final ComponentParameter cp, final MenuItem menuItem, final AbstractMVCPage templatePage) { final MenuItems al = MenuItems.of(); for (final IModuleContext ctx : ModuleContextFactory.allModules()) { final Module module = ctx.getModule(); MenuItem moduleItem = null; final ModuleFunction defaultFunction = ModuleFunction.getFunctionByName(module.getDefaultFunction()); if (defaultFunction instanceof WebModuleFunction) { if (!defaultFunction.isDisabled()) { moduleItem = MenuItem.of(defaultFunction.getText()) .setUrl(((WebModuleFunction) defaultFunction).getUrl()); } } else { moduleItem = MenuItem.of(module.getText()); } if (moduleItem != null) { final MenuItems children = moduleItem.children(); doSubItems(ctx, children, null, defaultFunction); if (StringUtils.hasText(moduleItem.getUrl()) || children.size() > 0) { al.add(moduleItem); } } } if (isShowMainMenuSeparator(cp)) { int i = 0, j = 0; final int c = al.size(); while (++i < c) { al.add(i + j++, MenuItem.sep()); } } return al; }
static String toActionsHTML(final PageParameter pp, final AbstractHeaderPage page) { final StringBuilder sb = new StringBuilder(); if (pp.getLoginId() == null) { sb.append(page.str_Login(pp)); } else { sb.append("<div class='acts'>"); sb.append( ModuleContextFactory.get(IMessageWebContext.class) .toMyMessageElement(pp) .setId("AbstractHeaderPage_sup")); sb.append(SpanElement.SEP()) .append(page.str_User(pp)) .append(SpanElement.SEP()) .append(page.str_Logout(pp)); sb.append("</div>"); sb.append("<div class='user'>").append(page.str_Photo(pp)).append("</div>"); sb.append(BlockElement.CLEAR); sb.append(HtmlConst.TAG_SCRIPT_START); sb.append(AbstractHeaderPage.js_shake("#AbstractHeaderPage_sup .highlight")); sb.append(HtmlConst.TAG_SCRIPT_END); } return sb.toString(); }