Software AG Products 10.7 | Administering and Monitoring Business Processes | Working with webMethods Business Console | Administering Business Console | Customizing Business Console Using Gadgets | Code Samples
 
Code Samples
Following code samples demonstrate how you can configure events in your gadgets:
Triggering an Event With Payload to Load a Process Diagram
The following code sample is for loading a process diagram using the Process Diagram gadget.
//Payload creation
var payload = new Object();

//Following is an example process Instance ID; Use a valid process Instance ID.
payload["instanceId"] = "9ef9a0d0-ac8a-18e7-8e09-fffffffdc4ca";

//Triggering an event to load the process diagram
_this.$scope.eventBus.fireEvent(EventConstants.PROCESS_DETAILS_DASHBOARD_LOADED,
payload);
You must define a function inside the defineScope element of the gadget controller file (controller.js) and add an argument that takes the process Instance ID as an input parameter. For more information about the gadget controller file, see the Developing Gadgets for webMethods Business Console Guide.
_this.$scope.loadProcessDiagram = function(processInstanceId){

//Your custom code, if any

var payload = new Object();
payload["instanceId"] = processInstanceId;
//For example, "9ef9a0d0-ac8a-18e7-8e09-fffffffdc4ca";

//Triggering an event to load the process diagram
_this.$scope.eventBus.fireEvent(EventConstants.PROCESS_DETAILS_DASHBOARD_LOADED,
payload);

//Your custom code, if any
};
Additionally, call the function from the gadget view file (view.xhtml) and pass the process Instance ID as a parameter. For more information about the gadget view file, see the Developing Gadgets for webMethods Business Console Guide.
//Call the function using a button.
<button data-ng-click="loadProcessDiagram('9ef9a0d0-ac8a-18e7-8e09-fffffffdc4ca')">
Load Process Diagram
</button>
You must add the Process Diagram gadget and your gadget to the same AppSpace.
Triggering an Event Without Payload to Refresh the Task Header
The following code sample is for refreshing the task header using the Task Header gadget.
//Triggering an event to refresh or reload
//task header in the “Task Header” gadget
_this.$scope.eventBus.fireEvent(EventConstants.LOAD_TASK_HEADER_DETAILS);
You must define a function inside the defineScope element of the gadget controller file.
_this.$scope.refreshTaskInformation = function(){

//Your custom code, if any

//Triggering an event to refresh or reload
_this.$scope.eventBus.fireEvent(EventConstants.LOAD_TASK_HEADER_DETAILS);

//Your custom code, if any
};
Additionally, call the function from the gadget view file.
//Calling the function from a button.

<button data-ng-click="refreshTaskInformation()">
Reload Task Information
</button>
You must add the Task Header gadget and your gadget to the same AppSpace. The Task Header gadget must be configured with a valid task ID.
Triggering an Event with Custom Data to Load Experts
The following code sample is to load a list of experts for a task type using the Task Experts gadget.
//Define custom data or direct payload
//Task type is the name of the task type for
//which user endorsements have to be loaded
var taskTypeName = “DefaultTask”;

//Triggering an event to load a list of task
//experts with taskTypeName as custom data
_this.$scope.eventBus.fireEvent(EventConstants.LOAD_EXPERTSPANEL,
taskTypeName);
You must define a function inside the defineScope element of the gadget controller file and add an argument that takes the task type as an input parameter.
_this.$scope.loadTaskExperts = function(taskTypeName){

//Your custom code, if any
//Triggering an event to load a list of task experts with
//taskTypeName as custom data
_this.$scope.eventBus.fireEvent(EventConstants.LOAD_EXPERTSPANEL, taskTypeName);

//Your custom code, if any
};
Additionally, call the function from the gadget view file and pass the task type as a parameter..
//Calling the function from a button.

<button data-ng-click="loadTaskExperts('DefaultTask')">
Load Task Experts
</button>
You must add the Task Experts gadget and your gadget to the same AppSpace.
For more information about developing gadgets, see the Developing Gadgets for webMethods Business Console Guide.