« August 2006 »
SunMonTueWedThuFriSat
  
1
3
4
5
6
9
11
12
13
16
17
19
20
23
24
26
27
28
31
  
       
Today
XML

Blog::Navigation

GetJava Download Button
Get the Source
Personal Blog

Blog::Referers

Today's Page Hits: 3

Powered by Roller Weblogger.
« Previous day (Aug 28, 2006) | Main | Next day (Aug 30, 2006) »
20060830 Wednesday August 30, 2006

Scriptlets

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.



( Aug 30 2006, 09:07:34 PM IST ) Permalink Comments [1] del.icio.us | furl | simpy | slashdot | technorati | digg

Copyright (C) 2005, A. Sundararajan's Weblog