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 | JavaScript |
---|---|
java.lang.Boolean | JavaObject object |
java.lang.Double | JavaObject object |
java.lang.Integer | JavaObject object |
java.lang.String | JavaObject object |
netscape.javascript.JSObject | generic JavaScript object |
all other Java objects | JavaObject object |
The return values will conform to the following conversions as they are passed between the environments:
JavaScript | Java |
boolean primitive | java.lang.Boolean |
number primitive | java.lang.Double |
string primitive | java.lang.String |
JavaObject object | The encapsulated Java object unwrapped |
all other JavaScript objects | netscape.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.
Prev | Home | Next |
JSObject object | Up | JSObject.eval() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |