Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • IBM Mashup Center wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 2.0
  • 3.0
  • 3.0.0.1
  • action widgets
  • actions
  • admin
  • administering
  • administration
  • administrator
  • adminstering
  • Ajax
  • AJAX proxy
  • annotate function
  • annotator
  • API
  • api reference
  • benchmark testing
  • catalog
  • configuing
  • configuration
  • configure
  • configuring
  • creating
  • creating mashups
  • data
  • data mashup builder
  • data mashups
  • database
  • DB2
  • demo
  • deploy
  • deployment
  • designing applications
  • developer
  • developing
  • developing mashups
  • developing widgets
  • documentation
  • ECM Widgets
  • editing
  • Enterprise Content Management Widgets
  • errors
  • events
  • examples
  • explanations
  • feed
  • feed mashups
  • feeds
  • format
  • functions
  • getting started
  • greenhouse
  • guide
  • IMS database feeds
  • IMS feeds
  • IMS transaction feeds
  • installation
  • installing
  • mashup
  • MashupHub
  • mashuphub examples
  • mashuphub users guide
  • mashups
  • messages
  • migrating
  • objects
  • operators
  • Oracle
  • pages
  • payload types
  • pdf
  • performance
  • performance tuning
  • planning
  • product
  • programming
  • proxy
  • rest services
  • security
  • service
  • spaces
  • themes
  • troubleshooting
  • tutorial
  • tutorials
  • upgrading
  • user
  • users
  • v1.0
  • v1.1
  • v2.0
  • v2.0.0.2
  • v4.5.2.1
  • video
  • WAR
  • widget
  • widgets
  • widgets
  • wire
  • YouTube
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Configuring > Hiding selected Mashup Center menu items
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Hiding selected Mashup Center menu items 

expanded Abstract
collapsed Abstract
As an administrator, you might want to hide certain context menus on the main Mashup Center page and in the space manager from users.
ShowTable of Contents
HideTable of Contents
  • 1 Adding a visibility-provider handler on a JavaScript page
  • 2 Hiding the action bar buttons in the space manager
  • 3 Removing the modeSelector widget from pages
  • 4 Installing the examples into your own Mashup Center environment
As an administrator, you can hide certain context menus on the main Mashup Center page and in the space manager from users. To hide menus, do the following steps:
 

  1. Locate the MashupCenter_install_root/mm/ContextMenu_Provider/contextmenu.xml file and make a backup copy. This copy ensures that you always have a functioning file in case you make errors in the copy that you will edit in the next few steps. A file with errors will not load, and no menus will display on Mashup Center pages. Also, be sure to test changes incrementally so that you can identify and correct problems quickly.

  2. Open the XML file in an editor. This XML file contains a list of all the context menus that are available on the main Mashup Center page and in the space manager.

  3. For each menu that you want to hide, add the following content. Note that this is just an example:
    <cm:contextMenuItem id="Edit">
        <cm:title>
            <!--@action.edit@-->
            <base:nls-string xml:lang="en">Go to Edit</base:nls-string>
        .....
        </cm:title> 
            <cm:description>Go To Edit Desc</cm:description>
            <cm:visibility-provider>com.ibm.mm.extensions.adminVisibilityOnly</cm:visibility-provider>
            <cm:action-handler>this.onEdit</cm:action-handler> 
    
    
    </cm:contextMenuItem>

  4. Save your changes.

  5. In a command window, change to the MashupCenter_install_root/Config directory and run the following commands:

    • ./config.sh (or config.bat) mashup-admin-command-config-property-blob

    • ./config.sh (or config.bat) update-was-config (standalone)

    • /config.sh (or config.bat) update-was-config-cluster (clustered environment)



  6. Restart the server or cluster to initialize the changes in the contextmenu.xml file.
        
 
Here are some examples that you can try:
 

Adding a visibility-provider handler on a JavaScript page


You can specify a visibility-provider handler that works with the contextmenu element in the steps above. The handler is contained on a JavaScript page.
In one implementation, the following snippet and the items following were added to a file named extensions.js:
 
/* 
 * This function returns true if the user is an administrator, otherwise false
 * use it to set a visibility-provider for Contextual menus in contextmenu.xml 
 */
dojo.provide("com.ibm.mm.extensions.adminVisibilityOnly");
com.ibm.mm.extensions.adminVisibilityOnly = function() {
    var permission =
        com.ibm.mashups.enabler.ac.AccessFactory.getEffectiveAccessVirtualResource(com.ibm.mashups.enabler.ac.VirtualResourceType.SPACE);
    if (permission.hasRole(com.ibm.mashups.enabler.ac.RoleType.ADMIN)) {
        return true;
    } else {
       return false;
    }
};
 
 

Hiding the action bar buttons in the space manager


The following function hides the action bar buttons in the space manager from non-administrator users:

/* 
 * This function hides the Create Space and Import Space buttons in the space manager.

 */
(function(){
var factory =
        (typeof com.ibm.mashups.enabler.space.Factory == "undefined")?com.ibm.mashups.enabler.model.Factory:com.ibm.mashups.enabler.space.Factory;
var original = factory.getSpaceModel;
factory.getSpaceModel = function() {
    var model = original();
    var originalCreate = dojo.hitch(model,model.confirmCreate);
    model.confirmCreate = function() {
        var permission =
            com.ibm.mashups.enabler.ac.AccessFactory.getEffectiveAccessVirtualResource(com.ibm.mashups.enabler.ac.VirtualResourceType.SPACE);
        if (permission.hasRole(com.ibm.mashups.enabler.ac.RoleType.ADMIN)) {
            return originalCreate();
        }
        else {
           return false;
        }
    };
    var originalCopy = dojo.hitch(model,model.confirmCopy);
    model.confirmCopy = function(node) {
        var permission =
            com.ibm.mashups.enabler.ac.AccessFactory.getEffectiveAccessVirtualResource(com.ibm.mashups.enabler.ac.VirtualResourceType.SPACE);
        if (permission.hasRole(com.ibm.mashups.enabler.ac.RoleType.ADMIN)) {
            return originalCopy(node);
        }
        else {
           return false;
        }
    };
    return model;
}


})();
 
 

Removing the modeSelector widget from pages


The following function removes the modeSelector widget from pages for users who are not administrators.The modeSelector widget, which is located at the top right of many pages, lets users switch between View and Edit modes. Permissions are determined according to the code samples above.

If non-administrator users are logged into a page, the modeSelector widget is removed from the page. The function subscribes to an event from the Mashup Center eventService to detect when the modeSelector widget is loaded in the page.
 

/* 
 * This function in an addOnLoad will remove the modeselector widget from a page for non-admins.
 * Since that is hidden, the menus alongside are also gone
 * This version uses a setTimeout rather than subscribing to an event
 */
dojo.addOnLoad(function(){
    var eventService = com.ibm.mashups.services.ServiceManager.getService("eventService");
    var func = function() {
        var modeSelector = dojo.byId("modeSelector");
        var permission =
            com.ibm.mashups.enabler.ac.AccessFactory.getEffectiveAccessVirtualResource(com.ibm.mashups.enabler.ac.VirtualResourceType.SPACE);
        if (modeSelector && !permission.hasRole(com.ibm.mashups.enabler.ac.RoleType.ADMIN)) {
            modeSelector.style.display = "none";
            dojo.destroy(modeSelector);
        }
    };
    eventService.subscribeEvent(com.ibm.mashups.iwidget.Constants.WIDGET_LOADED+"."+"modeSelector",this,func);
});


 
 

Installing the examples into your own Mashup Center environment


To try out the examples above in your own installation of Mashup Center, do the following steps:

  1. Download the Extensions.war file to your computer.

  2. Use the WebSphere Application Server administrative console to install the WAR file in the context root/extensions directory.

  3. Start the WAR file.

  4. Go to Resource environment providers > Mashups_ConfigService > Custom properties and add the following properties:

    • Name: com.ibm.mashups.common.js

    • Value: /extensions/js/extensions.js


  5. Save the configuration.

  6. Refresh the page. You can use a debug utility such as Firebug in Firefox or Fiddler2 in Internet Explorer to verify that the page is gets loaded properly.


expanded Article information
collapsed Article information
Category:
Configuring
Tags:
menus configuration customization pages

This Version: Version 30 June 29, 2011 8:03:45 AM by Anna G O'Neal  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (30)
collapsed Versions (30)
Version Comparison     
Version Date Changed by               Summary of changes
This version (30) Jun 29, 2011 8:03:45 AM Anna G O'Neal  
29 Jun 29, 2011 7:47:32 AM Anna G O'Neal  
28 Jun 29, 2011 7:46:31 AM Anna G O'Neal  
27 Jun 29, 2011 7:45:14 AM Anna G O'Neal  
26 Jun 28, 2011 9:45:29 AM Anna G O'Neal  
25 Jun 28, 2011 9:36:28 AM Anna G O'Neal  
24 Jun 28, 2011 9:29:45 AM Anna G O'Neal  
23 Jun 28, 2011 9:22:38 AM Anna G O'Neal  
22 Jun 28, 2011 9:20:50 AM Anna G O'Neal  
21 Jun 28, 2011 9:19:56 AM Anna G O'Neal  
20 Jun 28, 2011 9:19:27 AM Anna G O'Neal  
19 Jun 28, 2011 9:18:40 AM Anna G O'Neal  
18 Jun 28, 2011 9:11:08 AM Anna G O'Neal  
17 Jun 28, 2011 9:08:34 AM Anna G O'Neal  
16 Jun 28, 2011 9:08:05 AM Anna G O'Neal  
15 Jun 28, 2011 9:07:35 AM Anna G O'Neal  
14 Jun 28, 2011 9:06:08 AM Anna G O'Neal  
13 Jun 28, 2011 9:05:02 AM Anna G O'Neal  
12 Jun 28, 2011 8:55:29 AM Anna G O'Neal  
11 Jun 28, 2011 8:53:42 AM Anna G O'Neal  
10 Jun 21, 2011 7:54:52 PM Dirk Tysmans   grammar fixes
9 Jun 21, 2011 7:50:32 PM Dirk Tysmans   grammar changes
8 Jun 21, 2011 7:48:48 PM Dirk Tysmans   grammar checks
7 Jun 21, 2011 7:29:09 PM Dirk Tysmans  
6 Jun 21, 2011 7:04:00 PM Dirk Tysmans  
5 Jun 21, 2011 7:02:37 PM Dirk Tysmans   Added Javascript functions showing how to remove various elements from...
4 Jun 17, 2011 3:00:06 PM Dirk Tysmans  
3 Jun 17, 2011 2:44:43 PM Dirk Tysmans  
2 Jun 17, 2011 2:43:34 PM Dirk Tysmans  
1 Jun 17, 2011 2:36:47 PM Dirk Tysmans  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use