RichFaces rich:isUserInRole function

I blogged earlier about four built-in RichFaces functions that come in very handy, especially the rich:component(id) one. Many rich components (from rich;* tag library) provide client-side JavaScript API. To access this API, you need to use rich:component(id) and add the JavaScript method name, such as: #{rich:component(‘id’)}.someMethod(). For example, go to rich:listShuttle component in RichFaces Developers Guide and scroll to ReferenceData/JavaScript API section. That’s the JavaScript API you can call on this component.

There is one more, less known function available in RichFaces. It’s called rich:isUserInRole(role). It lets you define security roles in web.xml file and then use the role on a page. For example, suppose only the administrator should see some part of a page:

  Very sensitive information

   General information

In the above example, unless you were authenticated as ‘amdin’, you will not see the top panel. Of course you need the security role in web.xml file. It’s a nice and handy feature to have available.


  1. Thiago Pires says:

    Very good article. That was what I was looking for, but when I tried, it didn’t work
    this is the error:
    javax.servlet.ServletException: Function ‘rich:isUserInRole’ not found

    I tried using rich:menuItem:

    Do you Know why I doesn’t work?

  2. max says:

    What version RichFaces are you using?

  3. Bishnu (BJP) says:

    Is this possible to take the user role dynamically?

    like rendered=”#{rich:isUserInRole(bean.getRole())}” instead of

  4. max says:

    This will work:


    inside the bean you need to have getRole(). Calling a method might only be possible with JBoss EL extension (or in JSF 2).

Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.