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
IBM Translated Product Documentation...

 Developing with Mashup Center 3.0.0.1

 Planning, Installing, Configuring Mashup Center 3
 Enterprise Content Management Widgets 4.5.2.1 documentation

 IBM Mashup Center 2.0.0.2 documentation

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 > Developing with Mashup Center 3.0.0.1 > Adding client-side life cycle events to spaces
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars
(Current editable edition)
Original noneditable edition
Current editable edition
(Original noneditable edition)

Adding client-side life cycle events to spaces 

expanded Abstract
collapsed Abstract
This topic describes how to add client-side events to spaces and space templates. It explains how to add the required preference to a template so that it know where to locate the life-cycle extension. It also explains how to add the metadata to existing spaces using the Mashup Enable API. Finally, it provides an example of a JavaScriptâ„¢ (JS) file that you can create to define the life-cycle events.



This topic describes how to add client-side events to spaces and space templates. It explains how to add the required preference to a template so that it know where to locate the life-cycle extension. It also explains how to add the metadata to existing spaces using the Mashup Enable API. Finally, it provides an example of a JavaScriptâ„¢ (JS) file that you can create to define the life-cycle events.

Adding preferences to templates

To add client-side events to templates, you must add a preference to a template so that the template knows where to locate the JS file that contains the life-cycle extension. To add metadata, do the following steps:
  1. Locate the ZIP file for the template. For standard templates that are provided by default with Mashup Center, the ZIP file is located in the MashupCenter_install_root\mm\templates directory. For runtime templates, if you are using file-based persistence, the ZIP file is located in the MashupCenter_install_root\mm\public\template directory.
  2. Extract the ZIP file and open template.xml, which the definition XML file for the template.
  3. In an editor, under the <composite:business-component> element, add a preference by setting the preference name to com.ibm.space.extension_url and the value to the name of the JS file that contains the extension, as shown here:
    • <composite:preference name="com.ibm.space.extension_url">
                      <base:value value=
      "http://localhost:8080/mum/demos/js/test/enabler/
      resources/testSpaceExtension/alertSpaceExtension.js#AlertSpaceExtension" 
      readOnly="false" xsi:type="xsd:string" required="false"/>
                  </composite:preference>

  4. Save your changes.
Now, any new space that you create with this template will have life-cycle events.

Adding metadata to spaces

If you are working with an existing space, you can add metadata similar to the template preference by using the Mashup Enabler API. Refer to com.ibm.mashups.enabler.space.SpaceNode for more information. The name of the metadata is com.ibm.space.extension_url, and the value is the name of the JS file that contains the extension.

After the metadata is added, the space will begin to have life-cycle events. All copies of this space will inherit those events.

Creating a JS file that defines life-cycle events

When creating the JS file that defines life-cycle events for spaces and space templates, your implementation must extend the client-side SpaceExtension API and must be saved to the location that you specified in the metadata for the space or template, as described in the section above. If the location of the JS is remote, be sure to use a fully qualified URL.

Here is an example of a JS file that defines life-cycle events:

/* Copyright IBM Corp. 2009  All Rights Reserved.                    */
/**
 * Any JavaScript file that defines the subclass of 
SpaceExtension has three sections in order:
 * section 1: define the constructor of the subclass.
 * section 2: specify the prototype of the subclass.
 * section 3: overwrite all or part of the SpaceExtension methods.
 */
 
/**
 * section 1: define the constructor of the subclass.
 */
function AlertSpaceExtension() {
}
 
/**
 * section 2: specify the prototype of this subclass. 
The prototype should be the instance of superclass (SpaceExtension)
 */
AlertSpaceExtension.prototype = new SpaceExtension(); 
 
/**
 * section 3: overwrite all or part of the SpaceExtension methods.
 */
 
AlertSpaceExtension.prototype.onSpaceCreate = 
function(spaceId, 
spaceName, spaceDescription, optionalInfo) {
	alert("AlertSpaceExtension.onSpaceCreate \n spaceId = " +  
spaceId + "\n spaceName = " + spaceName + "\n 
spaceDescription = " + spaceDescription);
};
 
AlertSpaceExtension.prototype.onSpaceCopy = 
function(sourceSpaceId, targetSpaceId, optionalInfo) {
	alert("AlertSpaceExtension.onSpaceCopy \n sourceSpaceId = 
" +  sourceSpaceId + "\n targetSpaceId = " + targetSpaceId);
};
 
AlertSpaceExtension.prototype.onSpaceUpdate = 
function(spaceId, spaceData, optionalInfo) {
	alert("AlertSpaceExtension.onSpaceUpdate \n 
spaceId = " +  spaceId + " \n spaceData = " + spaceData);
};
 
AlertSpaceExtension.prototype.onSpaceDelete = 
function(spaceId, optionalInfo) {
	alert("AlertSpaceExtension.onSpaceDelete \n 
spaceId = " +  spaceId);
};
 
AlertSpaceExtension.prototype.canCopySpace = 
function(spaceId, optionalInfo) {
	alert("AlertSpaceExtension.canCopySpace \n 
spaceId = " +  spaceId);
};
 
// canExportSpace
// create a SpaceExtensionResult object as the return.
AlertSpaceExtension.prototype.canExportSpace = 
function(spaceId, optionalInfo) {
	alert("AlertSpaceExtension.canExportSpace \n 
spaceId = " +  spaceId);
};
 
// canDeleteSpace
// no return in this method. Which means ok.
AlertSpaceExtension.prototype.canDeleteSpace = 
function(spaceId, optionalInfo) {
	alert("AlertSpaceExtension.canDeleteSpace 
\n spaceId = " +  spaceId);
};


expanded Article information
collapsed Article information
Category:
Developing with Mashup Center 3.0.0.1, Product documentation, IBM Mashup Center 3.0.0.1 documentation, Product Documentation,
Tags:
developing mashups, spaces, pages, themes, widgets

This Version: Version 1 May 19, 2011 6:31:19 PM by IBM  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (1)
collapsed Versions (1)
Version Comparison     
Version Date Changed by               Summary of changes
This version (1) May 19, 2011 6:31:19 PM IBM  
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