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
- Implement a mechanism to trigger the script. For example,
create a button and put the script in a client
onclickevent. - Call the following method where
nameis the event name as defined on the Event tab andtypeis its type as defined on the Event tab. Thevalueis a string but must match the type in format.XSP.publishEvent(name, value, type)
Example
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");