Getting a JavaObject out of a JSObject

隐身守侯 提交于 2019-12-13 02:18:43

问题


I have a Javascript function in my xhtml page that does the following:

HTML FILE:

function getData(){
   var data = document.getElementById('data');
   return data;        
}

<input type="hidden" value="#{bean.bytes}"/>

Backing Bean Code:

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:

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); 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.

So my question is: How do I use JSObject to get a JavaObject?

Current method gets me back a String


回答1:


There is no data property.
Change it to returnedValue.getMember("value").



来源:https://stackoverflow.com/questions/4566346/getting-a-javaobject-out-of-a-jsobject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!