@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;
 }
 private void doSubItems(
     final IModuleContext ctx,
     final MenuItems children,
     final ModuleFunction parent,
     final ModuleFunction defaultFunction) {
   final ModuleFunctions functions = ctx.getFunctions(parent);
   if (functions != null) {
     for (final ModuleFunction function : functions) {
       if (function.isDisabled()) {
         continue;
       }
       if (!(function instanceof WebModuleFunction)) {
         continue;
       }
       if (defaultFunction != null && defaultFunction.equals(function)) {
         continue;
       }
       final MenuItem item =
           MenuItem.of(function.getText()).setUrl(((WebModuleFunction) function).getUrl());
       children.add(item);
       doSubItems(ctx, item.children(), function, defaultFunction);
     }
   }
 }