JavaScript -Applet Communication problem

Hi All,

Requirement : Onclick of particular location of loaded applet. I am calling JavaScript function which will render the table(as a popup like a bubble).

Problem Description:

I am calling below javascript function from Applet. Javascript function contains the code which create a table (popup). We have verified the JS function and it is displaying in normal HTML.

JavaScript Function

function CreateBubble(txt)

{

var t= GetElement('TABLE');

//t.style.background = 'white';

t.cellSpacing=0;

t.cellPadding=0;

var r,c;

r=t.insertRow();

c=r.insertCell();

c.innerHTML='<img src="images/nw.gif">';

c=r.insertCell();

c.innerHTML='<img src="images/n.gif">';

c.style.background = 'url("images/n.gif")';

c=r.insertCell();

c.innerHTML='<img src="images/ne.gif">';

r=t.insertRow();

c=r.insertCell();

c.innerHTML='<img src="images/w.gif">';

c.style.background = 'url("images/w.gif")';

c=r.insertCell();

c.style.background = 'url("images/1.gif")';

c.style.backgroundColor='white';

if(txt.tagName)

c.appendChild(txt);

else

c.innerHTML=txt;

c=r.insertCell();

c.innerHTML='<img src="images/e.gif">';

c.style.background = 'url("images/e.gif")';

r=t.insertRow();

c=r.insertCell();

c.innerHTML='<img src="images/sw.gif">';

c=r.insertCell();

c.innerHTML='<img src="images/s.gif">';

c.style.background = 'url("images/s.gif")';

c=r.insertCell();

c.innerHTML='<img src="images/se.gif">';

return t;

}

function GetElement(t){return document.createElement(t);}

-

When I call CreateBubble(txt) function from Applet. It is not rendering table. If i put the alert inside the function then it displays. I tried to debug by puttting alert before return statement of the JS function. It still display the alert box, but doesn't display the table.

I am not sure but the applet might be overshadow the table created through java-script.

This is my applet code:

publicvoid mouseClicked(MouseEvent e)

{

System.out.println("Mouse clicked in applet - Getting JSObject" );

System.out.println(("X, Y :" + e.getX() +"," +e.getY()));

//First segement point

if(e.getX() > 200 && e.getX() < 212){

JSObject jso = JSObject.getWindow( enclosingContainer );

System.out.println("Getting JSObject - SUCCESS" );

System.out.println("Invoking the script..." );

String [] args =new String[]{"acdd"};

jso.call("CreateBubble", args);

}

}

Let me know are there any other approach to do so?

Thanks

Chintan

[3360 byte] By [chintan_34a] at [2007-11-26 14:46:17]
# 1

Only pass strings between applets and JS. They both use unicode, so it works. Other data types, including primitive, don't work well.

In your JS code, you say, txt.tagName. This doesn't make sense if txt is a string.

Also, your Java code to call the JS looks funny. See the Java code in reply #11 in this thread: http://forum.java.sun.com/thread.jspa?forumID=421&threadID=482551

rkippena at 2007-7-8 8:33:54 > top of Java-index,Security,Cryptography...