Accessing java applet public variables
Jiri Vanek
jvanek at redhat.com
Wed Feb 19 01:48:21 PST 2014
On 02/18/2014 07:50 PM, JvR O wrote:
> I sent values to the signed applet.
>
> On 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";
>
> }
From your description is not clear whats wrong.
The access from applet is 100% working.
We have eg this tests
http://icedtea.classpath.org/hg/icedtea-web/file/d2563e68c74a/tests/reproducers/simple/AppletTakesLastParam/
and it is long term passing one.
>
> At javascript:
>
> var a = document.getElementById('appletid');
> var jstr = a.str;
>
> alert('jstr: '+jstr[0]);
From html - it is working to. But it is the question for browser then. Or not?
<html>
<body>
<applet
id="appletid"
codebase="/demo/"
code="appletpkg.appletclass"
archive="./sapplet.jar"
width="100px" height="100px">
<param name="valuename1" value="value1">
</applet>
<script>
function myFunction()
{
var a = document.getElementById('appletid');
var b = a.getElementsByTagName('param');
alert('jstr: '+b[0].getAttribute("value"));
}
</script>
<button type="button" onclick="myFunction()">Try it</button>
</body>
</html>
>
> If I use a similar script with ORACLE JRE on windows or mac the alerts shows a string.
>
> jstr: appletstringvalue1
>
> But if I use similiar script on ubuntu with OPENJDK I receive.
>
> jstr: undefined
>
> The java.log shows the value of jstr if I print to the log in both cases.
>
> Why Javascript is not receiving the applet values on linux or openjdk?
tbh this is the first time I'm seeing this approach. Not sure if it is standart on[1]
>
> The conversion of the objects (Java/Applet to JS) works correctly in the ORACLE JRE but with OPENJDK
> wich comes with linux (Ubuntu or Fedora, etc) is not working, or maybe I need to access to JavaArray
> in a different way?
>
>
> Any suggestion?
>
yes - use the DOM:)
But it donot exclude that this is bug in ITW.
j.
[1]
http://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html
..well they could not make it simpple...
This approach is heavily tested in ITW... But yes. The arrays have sometimes probelms.
More information about the distro-pkg-dev
mailing list