The Ajax Page Builder (APB) raises the alert EPCF event on certain occasions, such as when a user attempts to delete a module, or add a module when the maximum number of modules on a page is exceeded, or navigate from a module when its content has changed. You can use this event to raise alert dialogs in custom implementations of workspace UIs, such as the tabstrip.
The APB passes the eventObject object to the callback function. This object contains a dataObject, through which you can directly access the parameters relevant for an alert dialog box:
title: the title of the dialog box
text: the text of the dialog box
okLabel: the label for the OK button
cancelLabel: the label for the Cancel button
You can return the user's response to the alert dialog box to APB by raising the alertResponse event.
A map containing a response code:
1: OK
0: Cancel
To implement an alert dialog box, you should:
Subscribe to the alert event with a callback function:
EPCM.subscribeEvent( 'urn:com.sap.workspaces', 'alert', raiseAlert);
Implement the callback function, for example:
function raiseAlert(eventObject) { var dataObject = eventObject.dataObject; var alertTitle = dataObject.title; // Determine whether to show a confirmation dialog or a simple alert if (dataObject.okLabel == undefined || dataObject.cancelLabel == undefined){ alert(dataObject.text); response = true; } else { response = window.confirm(dataObject.text); } returnResponse (response) }
This sample displays standard alert dialog boxes, but you can implement a custom dialog box using the dataObject parameters.
Implement a function that returns the user's response to APB by raising the alertResponse event:
function returnResponse(response) { var map = new Object(); map.response = (response) ? "1" : "0"; // Return the user's response: “1” for OK, “0” for Cancel; EPCM.raiseEvent('urn:com.sap.workspaces', 'alertResponse', map); }