cancel
Showing results for 
Search instead for 
Did you mean: 

Using <r:permissionEvaluator> to selectively display c

lnagra
Champ in-the-making
Champ in-the-making
Apologies if this has already been answered, but I couldn't find it through a forum search.

I would like to take advantage of the <rSmiley TongueermissionEvaluator> tag that the Alfresco web client uses to selectively display controls through the web client.

I note that the typical use goes something like:

<r:permissionEvaluator value="#{NavigationBean.currentNode}" allow="Write" id="eval7">



</r:permissionEvaluator>

I'm assuming that NavigationBean.currentNode is pretty static and the allow property is the permission level you wish to apply (i.e. only users with write access see this), but I haven't worked out what the id property is used for.

Could you help me in understanding how to use this property in my own JSPs?

Thanks,

Lakhdip
5 REPLIES 5

kevinr
Star Contributor
Star Contributor
Hello,

You are correct in your assumptions on how the evaluator works.

The "id" attribute is simply the JSF component ID on the page - it can be any unique value for the page, it has no effect on how the evaluator works so you can set it to whatever string you like. The technical reason for this is subtle, some JSF components require IDs as they are added to the JSF View "late" in the lifecycle - mainly due to the fact that they may start life hidden from the component tree until some other action (e.g. expanded a panel area) exposes them for the first time. If in doubt, add a unique ID for your components, otherwise you don't need the "id" attribute at all.

There is a section on the basic evaluator tags here:
http://wiki.alfresco.com/wiki/Component_Library

But the permission evaluator is not mentioned specifically - however your guess on how it works is correct. The "value" attribute must resolve to a "Node" object that is used as the instance to check the permission such as "Write" or "Delete" against.

Thanks,

Kevin

lnagra
Champ in-the-making
Champ in-the-making
Thanks for your guidance Kevin.

Lakhdip

lnagra
Champ in-the-making
Champ in-the-making
Kevin,

I would like to have different users to see different sets of components on my pages. Your examples have them based on the rights they have in the current space (e.g. if they are allowed to delete content, expose the delete action in the UI).

How would it be best to implement the display of components based on their role (so, for example, if they are a consumer, don't display any actions. If they are a coordinator, display all space related actions etc.)

Alternatively, please let me know if you do not recommend this approach and would consider relying on individual 'write', 'delete' etc. level permissions as better.

Kind Regards,


Lakhdip

lnagra
Champ in-the-making
Champ in-the-making
Having thought about this some more, I believe what we need is an evaluator that validates against the user group. I can imagine such an evaluator working as follows:

e.g. <r:groupEvaluator value="#{NavigationBean.currentUser}" in="GROUP_EVERYONE"> 

would return true for everyone, but

<r:groupEvaluator value="#{NavigationBean.currentUser}" in="GROUP_Content_Administrators"> 

would only evaluate to true if the current user was a member of the Content_Administrators group.

Having read the wiki details on evaluators (http://wiki.alfresco.com/wiki/Evaluators#Custom_tag_attributes) could I simply extend or configure one of the existing evaluators to do this?

Thanks for your help,

Lakhdip

kevinr
Star Contributor
Star Contributor
That is a good idea for a useful evaluator. Evaluators are very easy to implement, there is already a base-class for the component and the tag classes can be copy/pasted from the existing ones. I would take a look at the source and give it a try! Smiley Happy

Cheers,

Kevin