Jsobject. Call () Java methodname
Jsobject. Call () Java method --- invoke a method of a JavaScript Object
Availability
Part ofNetscape. JavascriptPackage completed ded with navigator 3.0
Synopsis
public Object call(String methodName, Object args[])
Arguments
-
Methodname
-
The name of the JavaScript method to be invoked.
-
ARGs []
-
An array of Java object to be passed as arguments to the method.
Returns
A Java object that represents the return value of the JavaScript method.
Description
TheCall ()Method of the Java jsobject class invokes a named method of the JavaScript Object represented by the jsobject. arguments are passed to the method as an array of Java objects, and the return value of the JavaScript method is returned as a Java object. chapter 19,Liveconnect: JavaScript and JavaDescribes the data conversion was med to convert the method arguments from Java objects to JavaScript values and to convert the method return value from a javascript value to a Java object.
Eg: the foreground obtains parameters to change the panel width. The width is defined as a global variable in the panel class. If the front-end sets the JS parameter to 99 or not empty, the size is changed to 630; otherwise, the value is 800.
In the applet, you can set the Code as follows:
Try <br/> {<br/> jsobject win = jsobject. getwindow (applet); <br/> Object ret = win. call ("ispreschedule", null); <br/> If (Ret! = NULL) {<br/> This. view_width = 630; <br/>}else {<br/> This. view_width = 800; <br/>}< br/> catch (jsexception e) <br/>{< br/> joptionpane. showmessagedialog (null, E. getmessage (); <br/> E. printstacktrace (); <br/>}
Here, ispreschedule is the ispreschedule function defined in the JS file, or the JS function defined in the script of the JSP page:
Function ispreschedule () {// to resize applet for double <br/> var iscore = 99; <br/> return iscore; <br/>}