Hitachi

JP1 Version 12 JP1/Navigation Platform Content Editing Guide


5.12 APIs that can be used with JavaScript Plugin Parts

The following table describes the APIs (JavaScript APIs) that can be used with JavaScript Plugin Parts.

Table 5‒4: APIs that can be used with JavaScript Plugin Parts

Category

Class name

Description

Plugin manager

JavaScriptPluginManager

This class provides objects that allow JavaScript to perform processing provided by Navigation Platform.

REST caller

RestClient

This class invokes a URL from JavaScript.

To use an API, you have to acquire the JavaScriptPluginManager object by using the reserved variable ucnpJavaScriptPluginManager from JavaScript. Furthermore, if REST is to be invoked, you have to acquire the RestClient object by using the getRestClient method of the reserved variable ucnpJavaScriptPluginManager.

Because the methods (except the execute method) of the RestClient object return the RestClient object of the caller, they can be invoked with a method chain.

You can acquire the constant to be specified as the argument of the method of the RestClient object from the RestClient instance.

Note:

You can select the Execute in the browser check box so that a script with the following API methods can run on a web browser (on the client-side). In such a case, the API methods return Map or List arrays in a different format from when they run on a server.

  • getCurrentParamsTypeMap

  • getReturnMap

A Map indicates an associative array that contains key-value records while a List indicates an array that contains just a list of values. Note that, depending on whether to select the Execute in the browser check box, you need to use the API methods to handle Map or List differently as described in the following examples:

- Coding example 1: Get the type of the input parameter param0
  • When the Execute in the browser check box is cleared

var map = getCurrentParamsTypeMap();
var param0Type = map.get("param0");
  • When the Execute in the browser check box is selected

var map = getCurrentParamsTypeMap();
var param0Type = map["param0"];
- Coding example 2: Raise and highlight an error when the input parameter param0 is empty
  • When the Execute in the browser check box is cleared

var retMap = ucnpJavaScriptPluginManager.getReturnMap();
if (praram0 === "") {
  var errorParts = new java.util.ArrayList();
  errorParts.add("param0");
  retMap.put("ucnp.error.params.list", errorParts);
  retMap.put("ucnp.error.message", "error!");
}
  • When the Execute in the browser check box is selected

var retMap = ucnpJavaScriptPluginManager.getReturnMap();
if (praram0 === "") {
  var errorParts = [];
  errorParts.push("param0");
  retMap["ucnp.error.params.list"] = errorParts;
  retMap["ucnp.error.message"] = "Error!";
}
Organization of this section