myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "User-role Awareness" by MartinMarinschek
Date Mon, 19 Sep 2005 00:22:27 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by MartinMarinschek:
http://wiki.apache.org/myfaces/User-role_Awareness

New page:

The extended versions all support user-role-awareness: they have extra attributes {{{enabledOnUserRole}}}
and {{{visibleOnUserRole}}}. The values for these attributes are supposed to be comma separated
lists of user roles. If the current user has a role that is in this list, the component is
rendered '''enabled''', resp. '''visible''' (a better name for the latter attribute might
have been ''{{{renderedOnUserRole}}}'').

==== User Roles ====
User roles are a [http://java.sun.com/products/jaas/ JAAS] concept. The actual check happens
in the components by a call like
{{{
  if (facesContext.getExternalContext().isUserInRole(''role'')) {
    ...
  }
  else {
    ...
  }
}}}

For more information on user roles, see [http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/context/ExternalContext.html#isUserInRole(java.lang.String)
the JSF API documentation].

==== visibleOnUserRole ====
If the current user has one of the roles listed in the attribute {{{visibleOnUserRole}}},
the {{{rendered}}} attribute is used to decide whether or not to process the component. If
the current user does not have one of the roles listed in the attribute {{{visibleOnUserRole}}},
the the component is not processed (as if {{{rendered="false"}}} on a standard component).

Since the influence of the attribute {{{visibleOnUserRole}}} is actually implemented via the
standard {{{rendered}}} attribute, users should be aware that when the current user does not
have one of the roles listed in the attribute {{{visibleOnUserRole}}}, the component is not
processed ''in any phase''. Although the name refers to visibility, the attribute does influence
more than merely the ''rendering''.


==== enabledOnUserRole ====
If the current user has one of the roles listed in the attribute {{{enabledOnUserRole}}},
the {{{disabled}}} attribute is used to decide whether or not to render the component ''enabled''.
If the current user does not have one of the roles listed in the attribute {{{enabledOnUserRole}}},
the the component is rendered ''disabled''.

Note the reversal of logic from the standard {{{disabled}}} attribute to the extended '' '''not'''
disabled on user role'' {{{enabledOnUserRole}}} attribute.

Mime
View raw message