Pulpcore和JavaScript的Java Applet通信 [英] Pulpcore and Javascript to Java Applet communication
问题描述
我在使用 Pulpcore Java框架的一个问题。我试图用小程序在页面上从JavaScript调用Java函数。小程序正确嵌入页面(pulpcore产生的code)上。 JavaScript的code是:
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();
});
我甚至调试这个code和从DOM得到正确的小程序,但当时有这个JavaScript错误:
I even debugged this code and it gets applet from DOM correctly, but then there is this JavaScript error:
未捕获的异常:类型错误:'self.show2'不是一个函数
Uncaught exception: TypeError: 'self.show2' is not a function
这让我有点困惑。使用
document.pulpcore_object.show2();
给出了同样的错误。
gives the same error.
我不知道如果我失去了一些东西或者问题出在哪里。我甚至不能找到任何Pulpcore教程显示JavaScript来Applet通讯。
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.
推荐答案
这个答案被张贴f1ames作为内部问题的答案:
This answer was posted by f1ames as an answer inside the question:
这code工作:
$(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.
这篇关于Pulpcore和JavaScript的Java Applet通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!