Pulpcore and Javascript to Java Applet communication

无人久伴 提交于 2019-12-11 06:18:55

问题


I have a problem using Pulpcore Java framework. I tried to call Java function from JavaScript on the page with applet. The applet is correctly embedded on the page (pulpcore generated the code). The JavaScript code is:

$(document).ready(function() {
    var self = $("#pulpcore_object")[0];
    self.show2();
});

I even debugged this code and it gets applet from DOM correctly, but then there is this JavaScript error:

Uncaught exception: TypeError: 'self.show2' is not a function

which makes me little confused. Using

document.pulpcore_object.show2();

gives the same error.

I don't know if I'm missing something or where the problem is. I can't even find any Pulpcore tutorial showing JavaScript to applet communication.


回答1:


This answer was posted by f1ames as an answer inside the question:

This code works:

$(document).ready(function() {
    var applet = $("#pulpcore_object")[0];
    var scene = applet.getCurrentScene();
    scene.method();
});

So, we get the applet and then the main scene class and now we can call any public method from the scene class.



来源:https://stackoverflow.com/questions/7146725/pulpcore-and-javascript-to-java-applet-communication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!