From: Carl W. <wa...@ve...> - 2004-12-06 04:30:48
|
Is it possible to pass data back and forth between an applet written using Jython (compiled with jythonc) and JavaScript on the web-page. I have been attempting to write a very simple spread-sheet like grid applet, and I want to be able to pull some data out of its cells with JavaScript for use on the web page. I thought that maybe if I defined extra methods on the class I am deriving from JApplet, (e.g. setValueAt(value, x, y), getValueAt(x, y)), these would work, but when I try to access them from my JavaScript code, I get an error that those attributes don't exist. I wrote a couple lines of JavaScript to actually show what properties do exist, and all the public properties/methods from the JApplet class seem to be there, as well as some of the extra methods created during the jythonc compile (e.g. _PyGetInstance() -- might have spelled this one wrong). I can go to a jython interactive prompt, import my derived class, and do a dir() on it and see that my custom methods exist, so I am not quite sure what is going on. I have tried this on my WinXP machine using both Firefox 1.0 and IE 6. Both indicate that the attributes are not present. Firefox also has some strange behavior-- I put some HTML buttons on the page to execute the JavaScript I wanted to test the applet with, and immediately after I press the (HTML) button, the applet "resets", and all the data I typed in vanishes. This happens even if I comment out all the code in the JavaScript event handler. This behavior does not occur with IE, so I am not sure if this is just a browser bug (I am also not sure which browser would be displaying the buggy behavior-- for all I know, maybe I need some sort of code to make the applet repaint itself?). I am using JDK 1.5, but I am passing a "-source 1.2" to the javac compiler to get jythonc to compile-- I am not sure if this is a source of problems, either. The Java numbering/versioning schemes confuse me to no end. I can post my sample code if anyone is interested. Thanks, Carl Waldbieser |