• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Applet to Javascript Communication

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic