This post explains how to create dynamic menus based on the roles/user types in the ADF Web Application.
- Create the View Activities in the Task Flow
- Generate the menu model
- Bind the item nodes in the menu model with an EL
- 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
Department Role has access to Employees and Departments.
Login as DEPARTMENT/Welcome1
Ref: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/48-sitemenu-protection-169190.pdf
Sample application built using Jdev 12.1.3 can be downloaded from here.
Feel free to point out if anything is missing/wrong in this blog
No comments:
Post a Comment