Questo contenuto non è disponibile nella lingua selezionata.

4.6. Identifying User Roles


RichFaces also lets you check whether the logged-in user belongs to a certain user role with the rich:isUserInRole(Object) function. This function takes a String or a comma-delineated list of Strings, a Collection, etc. as arguments and returns a Boolean value.
As an example, imagine that you need to render some controls only for administrators. To do so, create an administrator role (admin) in your web.xml file. Then implement authorization that assigns the admin role to the user that has logged in as an administrator. Once this has been done, you can use the rich:isUserInRole(Object) function with the rendered attribute of any component. For example:
...
<rich:editor value="#{bean.text}"  rendered="#{rich:isUserInRole('admin')}" />
...
Copy to Clipboard Toggle word wrap
Here, only a logged-in user with an admin role can see the text editor, which will not be rendered for users with other roles.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat