Friday, May 9, 2014

OIM 11gR2 - Show and Hide UI elements based on a Role

OIM 11gR2 - Show and Hide UI elements based on a Role


Problem: You want to show or hide a button or field in OIM, but you want to do it based on the users role. For example, only Admins should be able to see the "Administration" panel in OIM.



Simple :-)

Here are the steps to do this.

First, login to OIM as xelsysadm or another admin that can create sandboxes.


Now that you have the sandbox and it is active, click the "Customize" button in the upper right corner of the screen. Once this is done, you need to click on "Source".


This will open up the WebCenter composer for you. You need to then select the panel or button you're looking to hide/show. For my example, I am going to modify the "Administration" panel.



As you can see, I clicked on the entire panel so that the box was around the entire object. You can choose just one item or button if you like, but for my example, we're just doing the Administration panel. You should see the "showDetailHeader: Administration" section highlighted now.

Next, click "Edit" from the menu.


We want to change the "Visible" item. We need to click the button next to "Visible" and choose "Expression Builder".


We want to add the string:

#{oimcontext.currentUser.roles['SYSTEM ADMINISTRATORS'] != null}

This string tells us a few things, it is using the OOTB managed bean for currentUser.roles and we are supplying the 'SYSTEM ADMINISTRATORS' role. Also, it has NULL which simply means if you do not have this role... HIDE !!

Next, click Test to make sure you're EL is correct and then "OK".

Finally, go back to your sandbox and export and then Publish.

** Side note, I always export before publishing any sandbox so that just in case something goes wrong I can edit the sandbox and fix or undo what I added.

Now, logout and log back in as a normal user.


DONE!

As I mentioned before, you can show or hide anything based on any role you create. Test this out and let me know what you find. I'm using OIM 11gR2 PS1.





2 comments:

  1. Hi i hope you having a nice day and thanks for example, its work fine... :)

    i just have a question, how do you do to validate that string begins with some king of pattern?

    I really appreciate your help

    ReplyDelete