• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet to Javascript Communication

 
Meena J
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a applet and i am trying to communicate with the javascript thr applet.
here is the code :
import netscape.javascript.*;
.
.
.
public class ReserveTable extends JApplet
{
public void init()
{
JSObject win = JSObject.getWindow(this);
JSObject doc = (JSObject) win.getMember("document");
JSObject form = (JSObject) doc.getMember("entry"); //entry is my form name
String s = (String) form.getMember("dateField");
.
.
.
}
}
When I try to run the Applet, It says...
"Exception:java.lang.ClassCastException:sun.plugin.javascript.ocx.JSObject"
Could anyone tell me what's the problem with this code...Please it's urgent...where I am goind wrong?
Thanks in advance.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Meena,
instead you can try writing a javascript method that returns the field you want and then use that method from the java code to call it.
you can then cast the return object back to String.
something like,
String s = (String)win.call("funcName", null) ;
well, i know this won't work if you really need to use many of the form field ...i have not thought about the solution in that case...

hope this helps you little.
regards
maulin.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meena J,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic