JSObject.call() (Java method)

Calls a method in the JavaScript object from the Java environment.


JavaScript - 1.1
Netscape - 3.0
Property/method value type:Object object
Java syntax:myJSObject.call("aMethod", anArgArray)
Argument list:aMethodThe name of a method to call.
anArgArrayAn array of arguments to pass to the method

This is the way in which a Java applet can call back to a JavaScript function in a page. Once you know the window, you can invoke methods that belong to it as well as access properties. This will always yield an Object object as a result.

There are quite restricted Java to JavaScript limitations on passing non-primitive values in the arguments array.

The values passed to JavaScript will conform to the following conversions as they are passed to the JSObject methods:

java.lang.BooleanJavaObject object
java.lang.DoubleJavaObject object
java.lang.IntegerJavaObject object
java.lang.StringJavaObject object
netscape.javascript.JSObjectgeneric JavaScript object
all other Java objectsJavaObject object

The return values will conform to the following conversions as they are passed between the environments:

boolean primitivejava.lang.Boolean
number primitivejava.lang.Double
string primitivejava.lang.String
JavaObject objectThe encapsulated Java object unwrapped
all other JavaScript objectsnetscape.javascript.JSObject

The result of this method call will be an Object object which needs to be cast to some other value for use in the Java environment.

See also:Call, Java to JavaScript values, JavaScript to Java values, JSObject object, JSObject.eval(), LiveConnect


Wrox Professional JavaScript - page - 542-3