views:

27

answers:

1

I would like to be able to call with javascript a function of my JNLP class. Let's assume in my applet I have a function defined like this: public String returnSomething(){ return "bla"; }

   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- ########################## IMPORTANT NOTE ############################ -->
<!-- This preview HTML page will work only with JDK 6 update 10 and higher! -->
<!-- ###################################################################### -->
<html>
    <head>
        <title>Test page for launching the applet via JNLP</title>
    </head>
    <body>
        <h3>Test page for launching the applet via JNLP</h3>
        <script src="http://java.com/js/deployJava.js"&gt;&lt;/script&gt;
        <script>
            var attributes = {
                code:       "winToJnaApi.NewApplet",
                archive:    "JavaApplication6.jar, lib/jna.jar, lib/platform.jar",
                width:      300,
                height:     300,
                name:       "applet",
                id:         "app"
            };
            var parameters = {jnlp_href:"launch.jnlp"}; <!-- Applet Parameters -->
            var version = "1.5"; <!-- Required Java Version -->
            deployJava.runApplet(attributes, parameters, version);
        </script>

    <input type = "button" value ="click" onClick = "document.write(document.getElementById("app").doSomething())">
    <script type="text/javascript">
        document.write(document.getElementById("app"));
    </script>
    </body>
</html>

Is this the proper way to call JNLP-deployed applet functions from javascript? Cause this one doesn't give me anything.

+1  A: 

I understand that applets launched using JNLP are no longer accessible to JS, but I might be wrong. To investigate it further, I would recommend removing the deployJava.js and hard coding the applet element.

Andrew Thompson
Seems to me like an unusual restriction/security consideration. If this is really the case, then I'm going to be a sad panda....
baba
I do not believe it has anything to do with security. The inter-applet communication that was standard in pre plug-in 2 JREs has also disappeared.
Andrew Thompson
So how am I supposed to invoke functionality of my applet? Only through controls in the applet itself ? If javascript is allowed to communicate with pure applets, shouldn't it be also be able to communicate with pure applets, deployed through Web Start.
baba
You have reached the limits of my knowledge about this subject. Sorry.
Andrew Thompson