1

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 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

4 Comments

It looks like using returnedValue.getMember("value") gives me back a String :(
@Vedar: That's because it is a string. What were you expecting?
well since the Bean returned a byte[] I was expecting a byte[] back.
The HTML DOM element's value property is a string, not a byte[].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.