Extending the AbstractDynamicMenu Class
Many SMS and Unstructured Supplementary Service Data (USSD) applications rely on menus to receive consumer responses. Menus reduce the potential for response errors, because they are numbered lists.
- A list of menu items
- Menus and indexes that are generated automatically and recalculated on each page
- Methods to send menus as SMS messages
- These variables:
- Show Exit Menu – an input variable that specifies whether to allow recipients to exit the menu.
- Variable Name of the Selected Key – an output variable representing the menu selection, which is stored as a key-value pair object. Key is the unique key of the menu item, which may be used later in the application.
- Variable Name of the Selected Value – an output variable that represents the value of the selected key.
- constructMenuList() – gets the menu list.
- init() – initializes the state.
- getStateAttributeList() – gets the list of attributes.
- saveSessionVariables() – explicitly saves session variables.
Message recipients can select from lists, and reply using index numbers. If a menu has more than four items, it includes a pagination option, which displays the next four items in the list. On the last page, selecting the pagination option returns to the first page. Selecting the exit option abandons a list without a response; the application task flow determines the follow-up transition. To force recipients to choose an item from the list, you can disable the exit option.
In a typical custom-state implementation that extends the SmappStatePlugin class, you implement state logic in the processStateLogic method. However, when you extend the AbstractDynamicMenu class, both processStateLogic and processMessageLogic methods are implemented by the abstract class. These methods contain the menu processing logic, and are declared as final, so they cannot be overridden.