Monday 23 March 2015

ADF: Dynamic Menu based on roles in ADF Web Application

This post explains how to create dynamic menus based on the roles/user types  in the ADF Web Application. 


When I wanted to create a dynamic menu for my application, I googled and found lots of videos/blogs on dynamic menus. In most of them, the dynamic behaviour was for the second level menu. Here I will explain how to achieve this for the first level menu itself.
  1. Create the View Activities in the Task Flow
  2. Generate the menu model
  3. Bind the item nodes in the menu model with an EL
  4. Use Navigation Pane to display the menu in the page
You can refer this video for creating a menu model in ADF Web Application.
  • Create the view activities in the adfc-config.xml. Right click and select 'Create and Update ADF Menu'.


  • Now the menu model is created. Now we can set the properties of each item Node. 
Here we set the rendered property of each item Node. These settings will reflect in the pages in the runtime. We can set the rendered property in various ways. Below mentioned are the 3 options which I am aware of.
   Option 1 : Based on Specific Role. 
      ex:- #{securityContext.userInRole['MANAGER-ROLE']}
   Option 2: Based on current SecurityContext, whether the user has access to the corresponding page Definition.
      ex:- #{securityContext.regionViewable['view.pageDefs.managersPageDef']}
   Option 3: Based on custom managedBean property. You can define a boolean variable in your Managed Bean                     (session scope) and use that as an EL. You need to set this variable after the login Activity.
      ex:- #{loginBean.dispManagerMenu}
Note:- ADF Security has to be configured for option1 and option2. The below screen shots are based in the option1.
  • Create a ADF page template and add a Navigation Pane.
       Note:- Make sure that you set the rendered property for the navigation item. This is the property which                   dynamically show/hide the menu during runtime.
  • Create the pages using this template.
  • ADF Security is configured as below.

                    Manager User --> Manager Enterprise Role --> Manager Role

                    Department User --> Department Enterprise Role --> Department Role


                     Manager Role has access to Employees and Managers.
                     Department Role has access to Employees and Departments.









  • Now lets run the page. 
           Login as MANAGER/Welcome1

           Login as DEPARTMENT/Welcome1



Sample application built using Jdev 12.1.3 can be downloaded from here.


Ref: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/48-sitemenu-protection-169190.pdf

Feel free to point out if anything is missing/wrong in this blog

No comments:

Post a Comment