Make Application Changes Visible Based on User Roles
This example demonstrates how you can make application changes visible to a specific user role.
To control page components conditionally based on user role:
-
Create security privileges
-
Add an Expression Language expression to the component property that you want to control
The following table summarizes the key decisions for this scenario.
Decisions to Consider |
In This Example |
---|---|
What's the page object you're securing? |
Reports link |
To which user role you want to make the changes visible? |
Hiring managers, Sherry Callaway and Terrance Whitaker Tip:
Create a role just for testing application changes.
Call it |
Which expression to add for verifying whether a user has the appropriate privilege? |
|
As a prerequisite, activate a sandbox that has the Page Composer tool in it. Make sure the context layer of your sandbox is supported by the page you want to edit. Otherwise, you won’t be able to edit the page.
Make Application Changes Visible to a User Role
Follow these steps:
-
Create a privilege.
-
Add the '
MANAGER_REPORTS_LINK_PRIV
' object to 'DEVCUST_TEST_ROLE
'. -
Assign
DEVCUST_TEST_ROLE
to Terrance and Sherry.Note:Make sure that Terrance and Sherry have access to the page before you make any changes.
-
Open the page, having the Reports link that you want to modify, in Page Composer, and select the Reports link component.
-
Click the Edit icon. This opens the Component Properties dialog box.
-
Click the Display Options tab.
-
Click the Edit icon next to the Show Component property, and select Expression Builder....
-
Add an expression to verify whether the user has the appropriate privilege. Use this sample code:
#{securityContext.userGrantedPermission['MANAGER_REPORTS_LINK_PRIV']}
-
Save the property changes, and close Page Composer.
After you change the show component property, whenever users open this page, the application evaluates the expression. Since Sherry and Terrance have the privilege, the Show Component property evaluates to be selected. Hence, Sherry and Terrance can see the Reports link while all other users can't.
Tip:Use Oracle JDeveloper to define permissions that render UI components based on the user's access rights. (Oracle JDeveloper is not available in Oracle Cloud implementations.)