[英]Getting a JavaObject out of a JSObject
I have a Javascript function in my xhtml page that does the following: 我的xhtml页面中有一个Javascript函数,该函数执行以下操作:
HTML FILE: HTML档案:
function getData(){
var data = document.getElementById('data');
return data;
}
<input type="hidden" value="#{bean.bytes}"/>
Backing Bean Code: 支持Bean代码:
public class Bean{
public byte[] getBytes(){
return this.bytes;
}
}
And I have an applet that needs to get this byte array from the html Applet code: 我有一个applet,需要从html Applet代码中获取此字节数组:
public class TestApplet extends Applet{
JSObject win = JSObject.getWindow(this);
JSObject returnedValue = win.call("getData", null);
}
I've been trying to call the returnedValue.getMember("value") (fixed) ; 我一直在尝试调用returnValue.getMember(“ value”) (固定) ; but that gets a null value. 但这得到一个空值。 I also tried to change the javascript to this: 我还尝试将javascript更改为此:
HTML: HTML:
function getData(){
var data = document.getElementById('data').value;
return data;
}
But that will only return me the String representation of the byte[], not the actual object. 但这只会返回字节[]的字符串表示形式,而不是实际的对象。
So my question is: How do I use JSObject to get a JavaObject? 所以我的问题是:如何使用JSObject来获取JavaObject?
Current method gets me back a String 当前方法让我回到字符串
There is no data
property. 没有data
属性。
Change it to returnedValue.getMember("value")
. 将其更改为returnedValue.getMember("value")
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.