Using the z/OSMF core JavaScript APIs
z/OSMF provides the zosmfExternalTools JavaScript API, which z/OSMF tasks can use to define actions to be performed before z/OSMF closes the task, to obtain a unique user session identifier, and to store and manage public objects in z/OSMF core.
The API is located at the following path: /zosmf/js/zosmf/util. To access the functions in the API and to dynamically add functions to the API, you must import and instantiate the zosmfExternalTools object in your task’s HTML file. Sample code is provided in Figure 1.
Figure 1. Sample JavaScript code for importing
and instantiating the global zosmfExternalTools object
require ([“dojo/_base/window”,”zosmf/util/zosmfExternalTools”],
function (win, zosmfExternalTools) {
win.global.zosmfExternalTools = new zosmfExternalTools();
});
For information about the functions that are included in
or can be added to the API, see the following sections:
Functions provided in the zosmfExternalTools API
Table 1 lists
the functions that are provided in the zosmfExternalTools API.
Function | Usage | Where described |
---|---|---|
programmaticallyCloseTab | Call this function to request for z/OSMF core to close your task. | programmaticallyCloseTab function |
cleanupBeforeDestroyComplete | Call this function to inform z/OSMF core that the actions performed by the cleanupBeforeDestroy function are complete. After which, z/OSMF closes your task. | cleanupBeforeDestroyComplete function |
getUserSessionId | Call this function to retrieve the unique session identifier that z/OSMF core creates for each user and z/OSMF instance combination. | getUserSessionId function |
definePublicObject | Call this function to define a public object in z/OSMF core. | definePublicObject function |
retrievePublicObject | Call this function to retrieve a public object from z/OSMF core. | retrievePublicObject function |
deletePublicObject | Call this function to delete a public object from z/OSMF core. | deletePublicObject function |
Functions you can add to the zosmfExternalTools API
Table 2 lists the
functions you can define and dynamically add to the zosmfExternalTools
API. z/OSMF core
calls these functions when specific events are triggered.
Function | Usage | When called | Where described |
---|---|---|---|
isContentChanged | Define this function if you want your task to check for unsaved changes before z/OSMF closes the task. | z/OSMF core
calls your isContentChanged function when:
|
isContentChanged function |
shouldClose | Define this function if you want to delay the close task request for an unspecified period of time so that your task can perform some additional actions. | z/OSMF core calls your shouldClose function when a user clicks the X icon to close the z/OSMF tab that contains your task. | shouldClose function |
cleanupBeforeDestroy | Define this function if you want to delay the close task request for up to one second so that your task can perform some cleanup actions before z/OSMF closes the task. | z/OSMF core
calls your cleanupBeforeDestroy function when a user:
|
cleanupBeforeDestroy function |