Application Menu

Application Menu Definition

Application menu is defined using <application.shortName>.menu file.

Example bookingApp.menu:

<?xml version="1.0" encoding="UTF-8"?>
<!-- expanded with nsx-expanders:4.13.0-SNAPSHOT, expansionResource net.democritus:Expanders:4.13.0-SNAPSHOT -->
<navigation xmlns="https://schemas.normalizedsystems.org/xsd/default-stack/2021/0/0/applicationMenu.xsd">
  <components>
    <!-- anchor:components:start -->
    <component name="utils"/>
    <component name="demoBooking"/>
    <!-- anchor:components:end -->
  </components>

  <menus>

    <!-- @anchor:menus:start -->
    <!-- @anchor:menus:end -->
    <!-- anchor:custom-menus:start -->
    <menu profile='admin'>
      <submenu name='Booking'>
        <menuitem ref='demoBooking-airport-list-page'/>
        <menuitem ref='demoBooking-person-list-page'/>
      </submenu>
      <submenu name='Config Data'>
        <menuitem ref='demoBooking-person-list-page'/>
        <menuitem ref='demoBooking-airline-list-page'/>
        <menuitem ref='demoBooking-location-list-page'/>
      </submenu>
    </menu>
    <menu profile="user">
      <submenu name="Booking">
        <menuitem ref='demoBooking-person-list-page'/>
        <menuitem ref="demoBooking-passenger-list-page"/>
      </submenu>
    </menu>
    <menu profile="default">
      <submenu name="Flights">
        <menuitem ref="demoBooking-flight-list-page"/>
      </submenu>
    </menu>
    <!-- anchor:custom-menus:end -->
    <!-- anchor:default-complete:start -->
    <menu profile="default-complete">
      <submenu name="Utils">
        <menuitem ref="utils-execution-list-page"/>
        <menuitem ref="utils-idCounter-list-page"/>
        <menuitem ref="utils-paramTargetValue-list-page"/>
        <menuitem ref="utils-tagValuePair-list-page"/>
        <menuitem ref="utils-thumbnail-list-page"/>
      </submenu>
      <submenu name="DemoBooking">
        <menuitem ref="demoBooking-airport-list-page"/>
        <menuitem ref="demoBooking-booking-list-page"/>
        <menuitem ref="demoBooking-flight-list-page"/>
        <menuitem ref="demoBooking-passenger-list-page"/>
      </submenu>
    </menu>
    <!-- anchor:default-complete:end -->

  </menus>
</navigation>

The file consists of menus with a profile attribute (in the example above: admin, user, default, default-complete).

When using the account component, the profileName of the current user user.profile.name is used. For JavaEE, the first profile defined in the menu file that the user has role of.

If no such profile in the menu exists, two fallbacks are used.

You can add a "default" profile to the custom-menus anchor. This will be used if the above selection hasn’t matched anything.

The menu also contains "default-complete" profile (starting with Expanders v4.13.0/default-stack v2021.1.0). This profile is not customizable, but contains all applicable components and dataElements. It’s main purpose is for debugging and quick iteration during development.

  • title title of the menu, usually the name of the element
  • selector where to inject the menu
  • menuName name of the .menu file
  • view reference to the html template for the menu
var Menu = require('nsx/menu');
//...
Menu.defineMenu({
  title: "...",
  selector: "menu",
  menuName: "...",
  view: menuTemplate
});