Just added scriptlet application to http://scripting.dev.java.net
A Scriptlet is a Java applet written in JavaScript. With scriptlets, developers
use a predefined applet class (called com.sun.scriptlet.Scriptlet)
and define an applet param which identifies a JavaScript. The JavaScript
code can define one or more script functions to "override"
applet's methods such as start, stop, init, destroy or paint.
By just defining paint function, scriptlet becomes equivalent to the new canvas tag.
But unlike canvas tag, scriptlet functions can access the entire
JDK API. The current applet object is exposed as first argument
to scriptlet's functions. For example, using this applet argument, scriptlets can play audio (by calling play method). With just the knowledge of JavaScript and Java API, very nice applets can be written.
Using
Java-to-Javascript Communication between Java to
browser's built-in JavaScript engine, a global variable named window
is defined. This window variable can be used by scriptlet scripts to access browser's script objects. For example, window.location.href returns the URL of the currently visited web page. Similarly window.document can be used to get the DOM document object of the current HTML page. Few simple scriptlets are in the applications/scriptlet/src/scriptlets directory of the scripting project.
Posted by Andres Almiray on August 30, 2006 at 10:59 PM IST #