Overview

You can define extension points for your custom elements, which reference JavaScript files with your custom code. You use methods from the Dojo class ExtensionMixin to select the context of your customization, style components with CSS, or retrieve data from the server.

First, you must define the property com.ibm.rules.decisioncenter.web.core.extensions.entrypoints with a list of extension point names, separated by a coma. These extension points are used for the Decision Center customization. This property must be located in a preferences.properties file in the application class path.

The extension point names reference JavaScript files, which contain the custom code. You can use one JavaScript file to define one or more extensions. You must define the custom code as a Dojo class, which inherits from the Dojo class ExtensionMixin (full path: com/ibm/rules/decisioncenter/extensions/ExtensionMixin).

Example

define([. . .,
           "com/ibm/rules/decisioncenter/extensions/ExtensionMixin"
             ], function(. . . , ExtensionMixin) {
	        return declare([ExtensionMixin], {
		  // Convenient methods to override. . .
               })
         })

The Dojo class ExtensionMixin provides you with methods to override that are invoked according to the context where you apply customization.

Table 1. List of methods to override
Method to override Context of the customization
ExtensionMixin::declareExtensions(/* Object */ data) In any view.

This method is called first when loading any new page. This lets you define extensions that can be used in all views. For example, custom property editors are needed for viewing properties in some views (Decision Artifact tab, rule editors, etc) so they must be declared with this method.

ExtensionMixin::inBranchView(/* Object */ data) Branch
ExtensionMixin::inReleaseView(/* Object */ data) Release
ExtensionMixin::inActivityView(/* Object */ data) Activity
ExtensionMixin::inSnapshotView(/* Object */ data) Snapshot
ExtensionMixin::inBusinessArtifactView(/* Object */ data) BAL rule or decision table
ExtensionMixin::inDecisionOperationView(/* Object */ data) Decision operation
ExtensionMixin::inDeploymentConfigurationView(/* Object */ data) Deployment configuration
ExtensionMixin::inRuleflowView(/* Object */ data) Ruleflow
ExtensionMixin::inTestSuiteView(/* Object */ data) Test suite
ExtensionMixin::inSimulationView(/* Object */ data) Simulation

Examples

To add your custom code in a branch, you must override the following method.
/* override/ inBranchView: function(/* Object */ data) {
	      // Your custom code goes here
}
To add your custom code in a deployment configuration, you must override the following method.
/* override / inDeploymentConfigurationView: function(/* Object */ data) {
	     // Your custom code goes here
}

The Dojo class ExtensionMixin also provides you with methods to style components with CSS files, or retrieve data from the server, which are described in the following sections.

Style custom components with CSS files

Reference

ExtensionMixin.loadCss: function(/* String */ cssPath)
Parameters
cssPath
The path to a CSS file that can be found in a class path.

Example

To load a CSS file, you must override the following method.
/* override */ inBranchView: function(data) {
    this.loadCss('/extensions/css/mystyle.css'); 
}

Retrieve data from the server

Reference

ExtensionMixin.sendRequest: function(pathMapping, xhrData, method)
Parameters
pathMapping
The path mapping to specific handler methods that are declared by a servlet on the server. The path mapping is prefixed by the URL to the server.
xhrData
The data to provide to the request, with the following scheme:
  • onSuccess: The method to call if the request succeeds.
  • onError: The method to call if the request fails.
  • parameters: The parameter to provide to the request.
  • scope: The scope to run to onLoad and onError.
methods
Can be either GET, POST, PUT, or DELETE.
Note: the path mapping of URLs must start with /ext/ to conform to the security scheme of Decision Center.