CRecordWebAddScript
The message
The message is part of the
The API is located in the plugin NY_
{ "id": "ebbe16ee-3f96-4068-ae8f-17cfd63f7c63", "name": "WEB_ADD_SCRIPT ", "description": "Add a script.", "slots": [ { "key": "1", "name": "ID ", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "The script ID." }, { "key": "2", "name": "CONTENT ", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "Optional: The content of the script." }, { "key": "3", "name": "SRC ", "direction": "REQUEST", "mandatory": "true", "type": "STRING", "description": "Optional: The source url of the script." } ] }
Arguments
-
ID : The ID of the script ensures that it can be removed when it is no longer needed. -
CONTENT : Either: the content of a Javascript file -
SRC : Or: the path to a Javascript file
Usage with the helper class CWebApi
The easiest way is to call the corresponding method in the CWebApi class. The use of the class is described there.
// Example: Load script from JAR resources Stringjs = CUtilJson.loadJson(getClass(), "/html/00401_graph.js") mWebApi.addScript("my_element_id" ,js ,null );
or
mWebApi.addScript(ID_SCRIPT2 ,null ,"https://d3js.org/d3.v7.min.js" );
Usage as message
The
public voidaddScript (@NotNull final CTargetAddressa , @NotNull final StringRemote Skin AddressaId , @Nullable final StringaContent , @Nullable final StringaSource ) throws CException {// Envelope final CEnvelope env = CEnvelope.forSingleTarget(m );Remote Skin Address// Record final CRecord record =CRecordWebAddScript .create();CRecordWebAddScript .setId(record,aId ); if (aContent != null) {CRecordWebAddScript .setContent(record,aContent ); } if (aSource != null) {CRecordWebAddScript .setSrc(record,aSource ); }// send message sendNotification(env, record); }