Helma Logo
main list history
previous version  overview  next version

Version 5 by hannes on 16. May 2008, 10:32

Helma NG provides a mechanism to bind Javascript functions as callbacks for certain 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|http://dev.helma.org/static/ng/api/org/helma/javascript/RhinoEngine.html* provides methods *addCallback()|http://dev.helma.org/static/ng/api/org/helma/javascript/RhinoEngine.html#addCallback(java.lang.String,%20java.lang.String,%20org.mozilla.javascript.Function)*, *removeCallback|http://dev.helma.org/static/ng/api/org/helma/javascript/RhinoEngine.html#removeCallback(java.lang.String,%20java.lang.String)*, and *invokeCallback()|http://dev.helma.org/static/ng/api/org/helma/javascript/RhinoEngine.html#invokeCallback(java.lang.String,%20java.lang.Object,%20java.lang.Object...)* to register, remove, and invoke callbacks.

=== Javascript API

The *helma.rhino module|http://dev.helma.org/trac/helma/browser/helma-ng/trunk/modules/helma/rhino.js* provides *addCallback(), removeCallback(), and invokeCallback() methods|http://dev.helma.org/trac/helma/browser/helma-ng/trunk/modules/helma/rhino.js#L34* to register, remove and invoke callbacks.

=== Callbacks used by Helma NG classes and modules

* onInvoke is called by *org.helma.javascript.RhinoEngine|http://dev.helma.org/static/ng/api/org/helma/javascript/RhinoEngine.html* immediately before request evaluation is started with the same arguments as the invocation.
* onRequest is called by the *helma.simpleweb|http://dev.helma.org/trac/helma/browser/helma-ng/trunk/modules/helma/simpleweb.js* module at the beginning of the handleRequest() method with the Request object as argument.
* onResponse is called by the *helma.simpleweb|http://dev.helma.org/trac/helma/browser/helma-ng/trunk/modules/helma/simpleweb.js* module at the end of the handleRequest() method with the Response object as argument.
* onLogEvent is called by *org.helma.util.RhinoAppender|http://dev.helma.org/static/ng/api/org/helma/util/RhinoAppender.html* with the formatted log message as argument and optionally a formatted stack trace as second argument.

     removed
     added