开发者

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

开发者 https://www.devze.com 2022-12-21 10:38 出处:网络
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\" be

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

精彩评论

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

关注公众号