Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6248469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:03:51+00:00 2026-05-24T13:03:51+00:00

I learnt how to use container authentication with JDBC realm. I searched a lot

  • 0

I learnt how to use container authentication with JDBC realm.
I searched a lot on internet but I couldn’t find anything on JSF authorization except the following article.
JSF authorization

My goal is to avoid access to protected pages using direct links and to show/hide menu items and form components based on the authenticated user privileges.
The last part can be implemented using the rendered attribute of JSF tags but before creating my own dirty and high coupled solution I wonder if there are some specific best practices or libraries that can help. in fact the number of components to be conditionally rendered is quite high and I wouldn’t like to write a specific function for each of them.
Perhaps I can create for each authenticated user a map with the names (id) of all the conditionally rendered components and a single function with a String parameter (the unique name/id of the component). Is that a good idea ? What alternatives do I have ?
I wouldn’t like to add to the project other general purpose frameworks such as spring for using only a small part of them (the security one).

Thanks
Filippo

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:03:52+00:00Added an answer on May 24, 2026 at 1:03 pm

    With the Expression Language version in Java EE 6 you should be able to use expressions like these:

    <h:inputText rendered="#{facesContext.externalContext.isUserInRole('foo')}" />
    

    With older versions, you can create a managed bean of this form:

    public class RoleMap implements Map<String, Boolean> {
    
        public Boolean get(Object key) {
            ExternalContext extCtxt = FacesContext.getCurrentInstance()
                                                  .getExternalContext();
            return extCtxt.isUserInRole(key.toString());
        }
    
        //TODO: other methods; mostly throwing UnsupportedOperationException
    

    The test can then be expression in the form:

    <h:inputText rendered="#{roleMap['foo']}" />
    

    Third party frameworks offer other options, such as the Apache Tomahawk library’s visibleOnUserRole component attributes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Despite using PHP for years, I've never really learnt how to use expressions to
Coming from another question of mine where I learnt not to EVER use db
I've just learnt a bit jQuery, and am trying to use it for a
I recently learnt Python. I liked it. I just wanted to use it for
In general I know how to use css but not advanced css So I
Last Edit: Resolved! Well, i was unable to find the ENTIRE answer here but
Should I learn to use Emacs with no intention to learn Lisp, if my
I'm trying to learn to use SDL for a little game I'm writing ,
I am trying to learn and use an SDK for a vendor's product. Unfortunately,
I am trying to learn to use buffer overflow attack in Ubuntu. Unfortunately, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.