[Bug 1794] New: LiveConnect - Problem with String arrays between Java and Javascript
bugzilla-daemon at icedtea.classpath.org
bugzilla-daemon at icedtea.classpath.org
Mon May 26 13:34:39 UTC 2014
http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=1794
Bug ID: 1794
Summary: LiveConnect - Problem with String arrays between Java
and Javascript
Product: IcedTea-Web
Version: hg
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P5
Component: NetX (javaws)
Assignee: omajid at redhat.com
Reporter: ldracz at redhat.com
CC: unassigned at icedtea.classpath.org
There is a problem with String arrays between Java/Javascript.
The problem is accessing a String Array made in Java from Javascript.
Here is an example where this occurs in IcedTea-Web but not in Java plugin.
The html
-------------------------
<html>
<body>
<div id="byids"></div><br>
<div id="writetojss"></div>
<br>
------------
<br>
<br>
<div id="byid"></div><br>
<div id="writetojs"></div>
<applet id='appletid' code='javatojs.JavatoJS'
archive='./sjavatojs.jar' width=1 height=1>
<param name="scriptable" value="true" >
<param name="mayscript" value="true" >
</applet>
<script type="text/javascript">
byids = document.getElementById("byids");
byids.innerHTML = "String by Id: "+appletid.myString;
byid = document.getElementById("byid");
byid.innerHTML = "StringArray by Id: " +
appletid.myStringArray[0] + ", " + appletid.myStringArray[1] + ", " +
appletid.myStringArray[2];
function writeToJS(myStringArray) {
tojs = document.getElementById("writetojs");
tojs.innerHTML = "StringArray by JSObject: "+ myStringArray[0] +
", " + myStringArray[1] + ", " + myStringArray[2];
}
function writeToJSs(myString) {
tojss = document.getElementById("writetojss");
tojss.innerHTML = "String by JSObject: "+ myString;
}
</script>
</body>
</html>
The java file
-------------------------
package javatojs;
import java.applet.Applet;
import netscape.javascript.*; // add plugin.jar to classpath during
compilation
public class JavatoJS extends Applet {
public String[] myStringArray = {"String a","String b","String c"};
public String myString = "String";
public void init() {
try{
JSObject window = JSObject.getWindow(this);
window.call("writeToJS", new Object[] {myStringArray});
window.call("writeToJSs", new Object[] {myString});
} catch (JSException jse) {
jse.printStackTrace();
}
}
}
Here is another example where with ORACLE JRE on windows or mac the alert shows
a string.
jstr: appletstringvalue1
But using a similar script on ubuntu with OPENJDK it appears as
jstr: undefined
The java.log shows the value of jstr if printed to the log in both cases.
Javascript is not receiving the applet values on linux or openjdk.
HTML:
<applet
id='appletid'
codebase="/demo/"
code='appletpkg.appletclass'
archive='./sapplet.jar'
width=1 height=1>
<param name="valuename1" value="value1">
</applet>
In the applet public class:
public String[] str = new String[100];
@Override
public void init() {
nstr = this.getParameter("valuename1");
//TODO
this.str[0]= "appletstringvalue1";
}
Javascript:
var a = document.getElementById('appletid');
var jstr = a.str;
alert('jstr: '+jstr[0]);
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20140526/e972991d/attachment.html>
More information about the distro-pkg-dev
mailing list