Publishing an event on the XPage with JavaScript

On the XPage, you can use a client-side script to publish a defined component event.

Procedure

  1. Implement a mechanism to trigger the script. For example, create a button and put the script in a client onclick event.
  2. Call the following method where name is the event name as defined on the Event tab and type is its type as defined on the Event tab. The value is a string but must match the type in format.
    XSP.publishEvent(name, value, type)

Example

Here are several examples:
XSP.publishEvent("publishString", "hello", "string");
XSP.publishEvent("publishNumber", "12", "number");
XSP.publishEvent("publishBoolean", "true", "boolean");
XSP.publishEvent("publishJson", {"userId": "jsmith"}, "JSON");
You can embed server JavaScript™ as the second parameter to publish values computed on the server. For example:
XSP.publishEvent("publishString", "#{javascript:document.myfield}", "string");