Hi @abd.ibrahim.allam,
The standard way to show/hide menu items for users is to use roles. There is an example in the manual as well.
When the user logs in, cuba platform will load the user permissions based on the roles that he has. Then, if any role grants access to the menu, the menu will be shown, otherwise not.
If your menu is not static, I would suggest you to use “Specific Permission” (search for “The Specific tab configures named functionality permissions” in the manual.
Then, when adding menu entries programatically, you can check if the user has permission before adding the menu entry:
Take a look at FilterDelegateImpl, method userCanEditFilers() to inspect how this functionality is used by the platform itself. Later you can update user permission changing the Role permissions (Specific tab).
I do really appreciate your support regarding my question .
I just want to clarify point regarding My custom Menu , it is menu defined on another xml file other than one defined inside web-menu.xml generated by Cuba ,
Hope you pass through Sampler application code , that will make you got over my point
While parsing my-custom-menu.xml I want to make same behavior as Cuba are doing for handling isPermitted over each menu item
That one can be handled by custom function , My Main Question is their any way to make if from Cuba Administration ,
Or shall I write custom function for fetching user roles and each menu item has role - with permission each role will be mapping at the end to screen which will be reflecting menu item
Hi @abd.ibrahim.allam,
I took a look at the Sampler app. I must admit I don’t understand why would you like to rewrite the menu from scratch, but I’ll share my thoughts on how I think you can do it.
I used cuba-petclinic project as an example for the instructions below.
For every screen on my-custom-menu.xml, I would create an entry in web-permissions.xml file (just like the sample in the documentation):
This step is required to enable the admin to setup permissions using cuba standard Role Edit screens.
Thanks for sharing information about how i can handle specific permissions
I will share with you , why I’m going to implement custom-menu - > If you want to create two menus inside your application which on my case , one menu containing Administration and Help on TOP and all other elements will be on the right side
If you know a way to put all menu items inside web-menu.xml and then display some on the Top menu using
<menu id="mainMenu" align="MIDDLE_LEFT"/>
and put the rest of the items on the side menu using the below line
<sideMenu id="sideMenu" width="100%"/>
as my situation their is no need to override even the side menu implementation as i’m opening the editor and browser screen not fragments as done on the sampler application
other wise from my thinking the only option to do so is to implement custom-menu
What I did is added both mainmenu item and sidemenu item on my main-window
Cuba by default will add all men items appearing on the web-menu.xml to both menus
Inside main-window-controlleronInit function just removing what ever i want not to appear on the top-menu and remove what ever i want to hide on the side-menu