Menu Manager API

In this Lesson

You will be introduced to the Soiree Menu Manager’s API which allows you to integrate a Solution’s menus into your scenes.

Concepts

The com.seronix.soiree.navigation.SoireeMenuManager class provides the following static methods

  1. UserMenu getMenu(Agent agent, String menuName)
    This method returns the full menu after it has been adapted to the user’s security profile. Any scenes not granted to the user will be removed as well as any sub-menu which are empty because of the trimmed scenes.
  2. UserMenuItem getCurrentMenuItem(Agent agent, String menuName)
    This API returns the menu item that was last selected by the user.
  3. STreeNode getMenuAsTree(Agent agent, String menuName)
    This methods returns the full menu in a structure suitable for displaying the menu in a tree element.
  4. boolean processMenuItem(Agent agent, String menuName, String menuItemPath)
    This method is used to process a menu item which has been selected by a user. If the item is a scene then a scene request will be made. If the item is a sub-menu then the menu will be traversed to the selected menu and the current menu item will be set to the selected sub-menu.
  5. boolean processMenuItem(Agent agent, String menuName, String menuItemPath, boolean clearContext)
    This is a variant of the processMenuItem method which clears the non-global context from the session before starting the scene.
  6. UserMenuItem getParentMenuItem(Agent agent)
    This method traverses the menu up to the menu item that is the parent of the current menu item and the current menu item will be set to the parent item.

Method 1 is illustrated in this lesson. Methods 2 – 6 will be illustrated in the lesson following this one.

Using the API to obtain a menu

In this example we will be using the API to read the following menu definition.



This is a code excerpt from an agent that responds to an event by obtaining the Primary Menu for the current user and displaying its contents in the Java console.



We will look at the output when we run this for three different users.

The first user has been granted access to all of the scenes in the menu



The second user does not have access to the com.example.party.scene.PartySplash scene



The third user only has access to the com.example.party.scene.PartyDefinition scene



Notice
The Security Scenes sub-menu was removed because the user could not access any of its scenes.

That concludes this lesson.