Callbacks
Helma NG provides a mechanism to bind Javascript functions as callbacks for arbitrary events. Events names can be freely assigned. By convention, Helma NG uses event names starting with "on", e.g. "onLogEvent".
It is possible to register multiple callbacks per event. The addCallback() and removeCallback() methods take a name argument to identify the callback. When a callback event is invoked, all callback functions are sequentially. If no callback is registered invokeCallback returns silently.
Java API
Class org.helma.javascript.RhinoEngine provides methods addCallback(), removeCallback, and invokeCallback() to register, remove, and invoke callbacks.
Javascript API
The helma.rhino module provides addCallback(), removeCallback(), and invokeCallback() methods to register, remove and invoke callbacks.
Callbacks used by Helma NG classes and modules
- onInvoke is called by org.helma.javascript.RhinoEngine immediately before request evaluation is started with the same arguments as the invocation.
- onRequest is called by the helma.simpleweb module at the beginning of the handleRequest() method with the Request object as argument.
- onResponse is called by the helma.simpleweb module at the end of the handleRequest() method with the Response object as argument.
- onLogEvent is called by org.helma.util.RhinoAppender with the formatted log message as argument and optionally a formatted stack trace as second argument.