Alert

Send an alert message to a user

The destination user has the same SITE_ID of the sender user.

In case you need to send a message to a user belonging to another SITE_ID, use the next method.

Syntax

utils.sendAlertMessage(from, message, destinations, priority, conversationId, messageTag)

Details

Note: in order to use this feature, you have first to define an application parameters named "SHOW_ALERT_MENU_ITEM" to "Y", otherwise these messages cannot be showed on the client side.

Send an alert message to a specific SITE_ID + username

The destination user is identified by the couple SITE_ID + username specified in input, so that the destination user can have a SITE_ID different from the one used by the sender user.

Syntax

utils.sendAlertMessage(from, message, siteId, destination, priority, conversationId, messageTag)

Details

Note: in order to use this feature, you have first to define an application parameters named "SHOW_ALERT_MENU_ITEM" to "Y", otherwise these messages cannot be showed on the client side.

Send a chat message to a user

The SITE_ID of the destination users is the same of the sender user.

Syntax

utils.sendChatMessage(from, message, destinations, priority, conversationId, messageTag)

Details

Note: in order to use this feature, you have first to define an application parameters named "SHOW_ALERT_MENU_ITEM" or "SHOW_CHAT_POPUP_MESSAGE" to "Y", otherwise these messages cannot be showed on the client side.

Send a not visible notification to the client

(available form 5.3.2) Send a notification to the client side; this is not a visual notification: it can be used to automate the invocation of a javascript method defined on the client. This automation can be helpful for example to open a window or reload a grid or form, when a server-side long operation has terminated.

You have to specify the function name and the argument to pass forward.

A limit it has is that you can only invoke functions having one only argument.

The SITE_ID of the destination users is the same of the sender user.

In case you need to send a message to a user belonging to another SITE_ID, use the next method.

Syntax

utils.sendJavascriptMessage(String from, Map obj, String destinations, String functionName)

Details

Note: in order to use this feature, you have first to define an application parameters named "SHOW_ALERT_MENU_ITEM" or "SHOW_CHAT_POPUP_MESSAGE" to "Y", otherwise these messages cannot be showed on the client side.

In case you need to invoke something from complex, you have to declare a one argument function in some global .js file (stored in the "scripts" folder of your application web context) and use it to do it.

Example of a global scoped js function with one argument, used to show a popup warning window:

function openDialogWindow(args) {
  showMessageDialog(
    args.title,
    args.message,
    function() {},
    true,
    true
  );
}

The server-side js action generating the notification would be:

utils.sendJavascriptMessage(
  "ADMIN", // from username
  { 
    title: "Warning",
    message: "Task completed"  
  }, // argument to pass forward to the client side js function
  userInfo.username, // not necessarely it would be filled out in this way
  "openDialogWindow"
);

Send a not visible notification to a client having a specific SITE_ID + username

(available form 5.3.2) Send a notification to the client side; this is not a visual notification: it can be used to automate the invocation of a javascript method defined on the client. This automation can be helpful for example to open a window or reload a grid or form, when a server-side long operation has terminated.

You have to specify the function name and the argument to pass forward.

A limit it has is that you can only invoke functions having one only argument.

The specific client is identified by the couple SITE_ID + username.

Syntax

utils.sendJavascriptMessage(String from, Map obj, Long siteId, String destination, String functionName)

Details

Note: in order to use this feature, you have first to define an application parameters named "SHOW_ALERT_MENU_ITEM" or "SHOW_CHAT_POPUP_MESSAGE" to "Y", otherwise these messages cannot be showed on the client side.

In case you need to invoke something from complex, you have to declare a one argument function in some global .js file (stored in the "scripts" folder of your application web context) and use it to do it.

Example of a global scoped js function with one argument, used to show a popup warning window:

function openDialogWindow(args) {
  showMessageDialog(
    args.title,
    args.message,
    function() {},
    true,
    true
  );
}

The server-side js action generating the notification would be:

utils.sendJavascriptMessage(
  "ADMIN", // from username
  { 
    title: "Warning",
    message: "Task completed"  
  }, // argument to pass forward to the client side js function
  userInfo.username, // not necessarely it would be filled out in this way
  "openDialogWindow"
);

Send an alert message to a user with a clickable callback

The sendAlertMessage function can be used also to include a clickable link which can be used to execute a js client side function.

This is possible since the message content is HTML based and therefore you can include a <A> tag to do it.

Example:

utils.sendAlertMessage(
  "ADMIN",
  "Click <a href='#' onclick='openWindowXXX()' >here</a> to open the window","ADMIN",
  null
);

Show a toast message

A toast message is a popup message shown starting from the top margin of the browser window, reporting a title and a text. The popup is automatically hidden after a few seconds.

Syntax

showToast(settings)

Details

Settings is a javascript object containing the following attributes:

Example on the UI

showToast({
    title: "common.warning",
    message: "data changed",
    sleep: 3,
    cls: "myCSSclassname"
});

The same example, starting from the server

var toastArgs = {
    title: "common.warning",
    message: "data changed",
    sleep: 3,
    cls: "myCSSclassname"
};
utils.sendJavascriptMessage(
  "ADMIN", // from username
  toastArgs, // argument to pass forward to the client side js function
  userInfo.username, // not necessarely it would be filled out in this way
  "showToast"
);

Last updated