For your Context object, do ctx.getWrapFactory().setJavaPrimitiveWrap(false);

Short explanation is that if you don't, your java.lang.Long will be seen as a JS Object, not as a JS number primitive, and Objects will be concatenated with other values as strings...

Attila.

On 2009.08.16., at 21:41, Alan Williamson wrote:

I have a java function:

--------------------
public Object func() throws Exception {
 return Long.valueOf("123");
}
--------------------

i have reduced the complexity of it right down, so you can see.

When i access this in my Javascript:

-----------
x = $cf.func();
y = x + 1;
-----------

x = 123 and y = 1231. If i multiple x by *1 then its fine. but thats a kludge.


How can i get Rhino to respect the fact i am returning a java.lang.Number for it to keep it as that, and not convert it to a string object?

thanks
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to