If you need to include a menu based on the GAM Permissions of the user in your application, the good news is that GAM dynamically creates the structure of the menu with no need for any extra coding.
GeneXus Access Manager (GAM) returns a menu structure that can be displayed using any User Control that is appropriate for displaying a hierarchical structure.
To do so, follow the steps below:
- Read Howto: Define a Menu using GAM to create the Menu of your WEB application.
- After you have created the GAM Menu in step 1, you can display it using any appropriate User Control; for example, the JScookMenu could be a good choice. Install the JSCookMenu in your development machine and create a web panel to include this User control in its form.
- Enter the following code to populate the User Control with the Menu data returned by GAM.
//&ApplicationGUID is the GUID of the GAM Application
//&MenuGUID is the GUID of the Menu
&MenuOptionList = GAMRepository.GetApplicationMenu(&ApplicationGUID,&MenuGUID, &Errors) //&MenuOptionList is
//GAMMenuOptionList data type
//The following procedure returns a collection of JSCookMenuItem given a GAMMenuOptionList collection
&MenuDataCollection = TransformGAMMenuToJSCookMenu(&MenuOptionList.Nodes)
For more information about the GAM API for handling Menus, read GAM API for menus.
4. The code of TransformGAMMenuToJSCookMenu is as follows:
JSCookMenuItem input &Menuitem in &Menu //&Menu is a collection of GAMMenuOptionList data type
Title = &Menuitem.Name
Url = &Menuitem.Link
Childs = TransformGAMMenuToJSCookMenu(&Menuitem.Nodes)
You can download the sample here.
Following very similar steps, you can use the TreeView (which is distributed in the standard UCs toolbox) instead of the JSCookMenu.
You can download the TreeView sample here.