AbstractDynamicMenu Life Cycle
The life cycle of the AbstractDynamicMenu class is based on the life cycle of the SmappStatePlugin class; however, there are slight differences in menu functionality.
If you extend the AbstractDynamicMenu class, it implements the processMessageLogic method and the processStateLogic method.
- The processStateLogic method calls the init method.
- processStateLogic calls both the constructMenuList and saveSessionVariables methods.
- The SmappStatePlugin::getStateAttributes method calls getStateAttributeList, which aggregates the attributes returned by the method with attributes defined in the AbstractDynamicMenu class, such as the input exit-menu item and the output key-value pair.
- An AbstractDynamicMenu state is initially activated as a follow-up transition from a previous state, so the processing engine calls its processStateLogic method. The init and constructMenuList methods are called sequentially to initialize and construct the menu. Eventually, the menu is sent as an SMS message, and the processing engine waits for the response. The consumer selects a menu item.
- If constructMenuList returns only a single item, the state immediately calls saveSessionVariables, and proceeds with the default dynamic follow-up transition. You can customize the state's default behavior by overriding the continueWhenSingleEntry method.
- When a response arrives, the processing engine calls the state's processMessageLogic method, which calls constructMenuList to assemble the menu and interpret the selected menu item. If the selection is a valid menu item, saveSessionVariables is called. The state prepares the selected-item details for output, and proceeds with the follow-up transition, as returned by the saveSessionVariables method. If null is returned, the default OK follow-up transition is used.