简体   繁体   English

转换Java对象-> JavaScript->从Applet读取

[英]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. Bean从数据库检索数据,我需要将其存储为网页上的隐藏字段。 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 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? Edit2:看来我有一些使用JSObject的数据,但是如何从JSObject检索数据? The data was stored as a DataHandler before it was read by javascript and acquired by the applet. 数据在被javascript读取并由applet获取之前已存储为DataHandler。 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. 我正在研究JSObject的getClass()方法调用,但它为我提供了HTMLInputElement,我不确定从那里去哪里。

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. 不知道为什么选择使用Applet,但是从最近的JDK起(我认为不确定JDK 1.6),Applet可以访问Javascript变量和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. JSObject类可帮助您从Java小程序访问Javascript。 http://java.sun.com/products/plugin/1.3/docs/jsobject.html 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 更新:实际上,它比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. 如果您需要访问页面的HTML结构,则也可以以相同的方式访问DOM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM