开发者

How do I convert an existent JavaScriptObject to a java primitive type in GWT?

Supposing that I have a reference to an exi开发者_高级运维stent JavaScriptObject that holds a primitive type, like an int value, how can I get this int value?


Use the JSNI functionality to "adapt" between GWT's Java and underlying Javascript: more specifically, use the cast() method to adapt to the desired type. You can afterwards "repackage" the object to any Java primitive you want/can.

You might need to write a native method on a sub-class of JavascriptObject in order to "reach" the primitive type you are referring to. See this article for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜