Restricting a menu item to a specific Space
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2007 06:13 PM
I assume I need to use the "evaluator" and "condition" attributes (config tag) to do this, but I cannot find any documentation on how these are used. Should I be using the "string-compare" evaluator, and if so, how do I specify that I want this action restricted to a single space (and all documents and subspaces within it)?
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2007 12:14 PM
You can use either use the evaluator/condition couple in the config element (see http://wiki.alfresco.com/wiki/Web_Client_Configuration_Guide) or the evaluator tag inside the action element (see http://wiki.alfresco.com/wiki/Externalised_Client_Actions#Action_Definition_Config_Elements) depending on how complex your visibility rule is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2007 01:20 PM
Yes, I have seen those documents, but there is not much information on what evaluators are available (other than string-compare), and how to use them. For example, how exactly does string-compare work? Can it be used to restrict the config to a specific path? If yes, how can it be done?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2007 06:39 AM
The evaluator for config determines whether the whole config block should be used depending on the object used when a config lookup is done. There is a small amount of information on this here: http://wiki.alfresco.com/wiki/Config_Service
For your scenario though it sounds like an action evaluator is more suited, documentation on these can be found here: http://wiki.alfresco.com/wiki/Externalised_Client_Actions#Action_Definition_Config_Elements. For some real examples of action evaluators look in the 'org.alfresco.web.action.evaluator' package.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2007 07:29 AM
Thanks in advance. Elena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2007 09:10 PM
No, I was not able to achieve my goal using the Alfresco UI or XML customization out-of-the-box. As Gavin wrote, I needed to write a custom ActionEvaluator (Java class) that gets executed to check whether to display the menu item or not. Writing that Java class was easy enough, and once I put the .jar in the /WEB-INF/lib folder, I was able to use my custom ActionEvaluator without any problems. Let me know if you need more help…
Thanks,
Vasuki.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2007 07:30 AM
I'm going to try it. I hope not to have so much problems.
Thanks for your reply

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2007 07:52 AM
actually, what I can't understand is what Java class do I have to use in order to get the space name. If I had the space name, I would be able of comparing this name with my current space name.
I would like that "Firmar" action appears only in Firmado space:
I have tried this CompareSpace.java:
package org.alfresco.web.action.evaluator;
import org.alfresco.web.action.ActionEvaluator;
import org.alfresco.web.bean.repository.Node;
public class CompareSpace implements ActionEvaluator{
public boolean evaluate(Node node) {
return (node.getName().equals("Firmado"));
}
}
but it doesn't show anything.
Thanks in advance, Elena.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2007 11:57 AM
Your "evaluate" method is OK if the action is attached to the space itself (i.e. in the Create menu for instance) but if it is attached to a document in the space (like the "Edit" or "Show document details" actions), the node passed to the evaluate method is the document and not the parent space.
In this case you can test either the name of the primary parent of the node (first option) or the name of the current space using the navigation bean (second option) :
public boolean evaluate(Node node) { FacesContext fc = FacesContext.getCurrentInstance(); ServiceRegistry services = Repository.getServiceRegistry(fc); NavigationBean navigator = (NavigationBean) FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); NodeRef space = navigator.getCurrentNode().getNodeRef(); // check the current space name is "Firmado" return "Firmado".equalsIgnoreCase((String) services.getNodeService().getProperty(space, ContentModel.PROP_NAME)); }‍‍‍‍‍‍‍‍‍‍
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2007 01:01 PM
Sounds like rivarola knows a lot more about this stuff than I do. Here is the code I used since I wanted to restrict the action to a space and all of its subspaces:
public class MySpaceEvaluator implements ActionEvaluator{ public boolean evaluate(Node node) { return (node.getPath().contains("MySpace")); }}‍‍‍‍‍‍‍‍‍
