473,668 Members | 2,407 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java Applet<-->JavaScript communication (Firefox 3).

I only need to support Firefox 3 at the moment, so any advice can be
specific to that.

I have a Java Applet, lets call it HelperApplet.

It has one method of importance:
public Object doHelp(JSObject callback) {
System.out.prin tln(callback + "\n" + callback.getMem ber("foo"));
callback.call(" helped", new Object[] {callback.getMe mber("foo")});
return callback;
}

I have javascript that does this:

myCallback = documents.apple ts[0].doHelp({
foo: "bar",
helped: function(result ) {
alert(result);
}
});

Unfortunately, the callback doesn't get called. It appears the the
JSObject callback doesn't contain any members in Java land. Although, I
can access the returned object, eg myCallback.help ed("Broken Java") works.

Any advice? Work-arounds? Are my attempts probably going to be futile?

Thanks,
Daniel.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity .net/wordpress/>
Sep 24 '08 #1
1 5914
Daniel Pitts wrote:
I only need to support Firefox 3 at the moment, so any advice can be
specific to that.

I have a Java Applet, lets call it HelperApplet.

It has one method of importance:
public Object doHelp(JSObject callback) {
System.out.prin tln(callback + "\n" + callback.getMem ber("foo"));
callback.call(" helped", new Object[] {callback.getMe mber("foo")});
return callback;
}

I have javascript that does this:

myCallback = documents.apple ts[0].doHelp({
foo: "bar",
helped: function(result ) {
alert(result);
}
});

Unfortunately, the callback doesn't get called. It appears the the
JSObject callback doesn't contain any members in Java land. Although, I
can access the returned object, eg myCallback.help ed("Broken Java") works.

Any advice? Work-arounds? Are my attempts probably going to be futile?

Thanks,
Daniel.
I figured out a work around, not pretty, but it does the trick:

public class MyApplet extends JApplet {
private JSObject appletTmp;

public JSObject resolveObject(O bject o) {
final int hashCode = System.identity HashCode(o);
appletTmp.setMe mber("toResolve " + hashCode, o);
return (JSObject) appletTmp.getMe mber("toResolve " + hashCode);
}

public void init() {
if (appletTmp == null) {
final JSObject window = JSObject.getWin dow(this);
final String tmpName = "_AppletTmp " +
System.identity HashCode(this);
window.eval("va r "+ tmpName +" = {}");
appletTmp = (JSObject)windo w.getMember(tmp Name);
}
}

public Object doHelp(Object o) {
JSObject callback = resolveObject(o );
System.out.prin tln(callback + "\n" + callback.getMem ber("foo"));
callback.call(" helped", new Object[] {callback.getMe mber("foo")});
return callback;
}
}

--
Daniel Pitts' Tech Blog: <http://virtualinfinity .net/wordpress/>
Sep 25 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1546
by: Ronald Carter | last post by:
Ok, I go to http://sidestep.com and use the web interface to search a flight. When using Mozilla, if I click the calendar button to set the travel date, I get a little calendar window from which I can choose a travel date. But, using Firefox, I get no calendar. On other travels sites, such as Orbitz, Expedia and Travelocity, clicking the calendar button produces a (Java) calendar with Firefox. So, why would the SideStep calendar work...
2
1572
by: annie | last post by:
Hi all. Can Java classes/objects be used from within the javascript code on the HTML page? I.e., can I call a Java method from the javascript function? Thanks in advance Anna
1
6647
by: Uma | last post by:
DB2I.PROCEDURE1 - Build started. C:\SQLLIB\java\jdk\bin\javac -classpath ".;C:\SQLLIB\java\db2java.zip;C:\SQLLIB\java\runtime.zip;C:\SQLLIB\java\sqlj.zip" "PROCEDURE1.java" DB2I.PROCEDURE1 - Javac completed. C:\SQLLIB\java\jdk\bin\jar cf SQL40620024042610.jar PROCEDURE1.class DB2I.PROCEDURE1 - Jar file created. Call sqlj.install_jar ('file:///C|/Documents and Settings/Utalasila/Application...
1
9014
by: Praveen | last post by:
Hi, I have installed WebSphere Portal on AIX and connected to DB2 on a remote machine, Getting the followin errors when trying to get the values from database thru applications installed on Portal. Any Help Appreciated. Thanks in advance. Praveen Singh
4
6657
by: jediknight | last post by:
Hi, I am trying to establish whether I can have a C# socket server and Java socket clients. From all the examples I have seen on the web refer to Java Servers and C# clients. Can anyone point me in the direction of a C# socket server and Java client example?? Cheers
5
3787
mrjohn
by: mrjohn | last post by:
I've been experimenting with this Java applet and Firefox, but after I recompile the code and refresh/reopen the page, the changes are not reflected in the browser. Why's that? import java.applet.*; import java.awt.*; public class Program extends Applet { public void paint (Graphics g) {
3
5348
by: hash4sp | last post by:
Hello Can anyone here please guide me with the Cross Domain Communication between IFrames. Problem: Application1 running on IIS => http://localhost.ad.local/Applicaiton1 Application2 running on Apache => http://localhost.ad.local:8080/Application2 The Application2 is being loaded in an IFrame inside Application1; and there needed a communication beetween the two Applications. With IE my application works but with FireFox it doesnt.
0
1583
by: adbasque | last post by:
Hello, I am running a chat server with a java Applet unfortunately I don't have access to the source code, all I have are jars and classes. When I run the applet with FF2, IE, Safari and Opera I don't have a problem, but since I upgraded to Firefox 3, I' am getting the following error. java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unknown Source) at...
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8382
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.