How to create own application menu method?
The sample program was prepared for this purpose. In the QSAMPLES source file devlivered together with aperio You can find all sources ready to use as dynamic menu structure. The programs and files are ready to compile. You can copy it and adjust or change if needed.
Following sources contain necessary elements to build dynamic menu structure:
The menu structure is stored in MENU_STR. This file contains 3 columns:
- PARENTID id of parent menu item
- SEQ sequence
- CHILDID id of child menu items
Example of menu structure:
Next file MENU_ATTR contains attributes for each menu item. Following attributes are mandatory for mobile applications:
- ’title’ it contains title of menu item
- ‘form’ It contains form name which will be invoked when user click on menu item.
There is possibility to add more attributes:
- ‘icon’ It defines the menu item icon
- ‘method’ It defines method which will be run automatically for visual flows menu type and many more…
Example of MENU_ATTR file data:
Third file MENU_AUTH contains authority information. Each menu item must be defined here at least once. This file describes who has access to menu item. In the field USER it is possible to define iSeries profile or group profile connected to iSeries profile.
Example of MENU_AUTH data:
In the example above all users which have group profile IBS11OWN, have access to all menu items except A5 and A6. Only user ADMIN is authorised to menu items A5, A6. If user SALESMAN has no group profile IBS11OWN then he has access only to menu items: A, A1, A4, A41, A42
The MENU_GET program builds menu structure based on these 3 files. It retrieves iSeries profile information. The security is based on user profile, group profile and all supplemental group profiles. If there is need to implement any other security rule (e.g. based on different files) the recommendation is to do it in lcl_checkAuhority procedure (at the end of program). This procedure returns *ON, if user has authority to menu item, or returns *OFF, in case user has no authority to menu item. This program can be copied under any other name and compiled.
When program is ready, add to metadata following entry. This will expose program under name applicationMenu.get
Then in application definition json file, the top menu item of menu structure must be defined.
Example of application definition