Converting Java Object -> JavaScript -> Reading from Applet
I'm a bit stuck with this concept that I've been working on and I'm looking for some sort of guide on this. Essentially this is the problem:
Bean retrieves data from database and I need to store it as a hidden field on a webpage. The user then must authenticate the data using an applet. The resulting authenticated object is then sent to the database.
So i'm stuck at this paradigm:
Bean -> Html & Javascript -> Applet
I think I can figure out the upload issue later, thanks :)
Edit: Switch Authenticate with Sign :)
Edit2: It seems I have some data using JSObject but how do I retrieve the data from the JSObject? The data was stored as a DataHandler before it was read开发者_StackOverflow社区 by javascript and acquired by the applet. I'm looking into the getClass() method call from the JSObject but it gives me an HTMLInputElement and I'm not sure where to go from there.
Not sure why you chose to use Applets, but from recent JDKs onwards (I think its JDK 1.6 not sure) an Applet has access to the Javascript variables and HTML DOM. So yes you can do it... you might want to ask yourself why you want to go down this route though.
Some more info:
The JSObject class helps you access Javascript from a Java applet. http://java.sun.com/products/plugin/1.3/docs/jsobject.html
Update: Actually its much older than JDK 1.6 http://download.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/java_js.html
If you need to access the HTML structure of the page you can also access the DOM in the same way.
精彩评论