从 JSObject 中获取 JavaObject [英] Getting a JavaObject out of a JSObject
问题描述
我的 xhtml 页面中有一个 Javascript 函数,它执行以下操作:
I have a Javascript function in my xhtml page that does the following:
HTML 文件:
function getData(){
var data = document.getElementById('data');
return data;
}
<input type="hidden" value="#{bean.bytes}"/>
支持 Bean 代码:
Backing Bean Code:
public class Bean{
public byte[] getBytes(){
return this.bytes;
}
}
我有一个小程序需要从 html 中获取这个字节数组小程序代码:
And I have an applet that needs to get this byte array from the html Applet code:
public class TestApplet extends Applet{
JSObject win = JSObject.getWindow(this);
JSObject returnedValue = win.call("getData", null);
}
我一直在尝试调用returnedValue.getMember("value") (fixed);但这会得到一个空值.我也尝试将 javascript 更改为:
I've been trying to call the returnedValue.getMember("value") (fixed); but that gets a null value. I also tried to change the javascript to this:
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.
所以我的问题是:如何使用 JSObject 获取 JavaObject?
当前方法让我返回一个字符串
推荐答案
没有 data
属性.
将其更改为 returnedValue.getMember("value")
.
这篇关于从 JSObject 中获取 JavaObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!