Pulpcore and Javascript to Java Applet communication

352 Views Asked by At

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

There are 1 best solutions below

0
On

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.