java - cast JavaScriptObject to gwt widget - Stack Overflow

may i know how to cast JavascriptObject get from JSNI into gwt as gwt CUstomWidgetCustomWiget widget =

may i know how to cast JavascriptObject get from JSNI into gwt as gwt CUstomWidget

CustomWiget widget = (CustomWidget) javascriptObjectFromJSNI; //doesnt work

may i know how to cast JavascriptObject get from JSNI into gwt as gwt CUstomWidget

CustomWiget widget = (CustomWidget) javascriptObjectFromJSNI; //doesnt work

Share Improve this question edited Jan 16, 2011 at 8:03 etta asked Jan 16, 2011 at 7:12 ettaetta 35.8k84 gold badges220 silver badges329 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You cannot cast an ELement to a Widget. You can use GQuery to help you out in this case.

GQuery.$(element).widget() will give you the GWT widget you are looking for on your DOM.

You can use CustomWidget as the return type of your JSNI method. The example at http://code.google./webtoolkit/doc/latest/DevGuideCodingBasicsOverlay.html#example-json does this with Customer (which extends JavaScriptObject):

private native Customer getFirstCustomer() /*-{
  return $wnd.jsonData[0];
}-*/;

If your CustomWidget is really a Widget (not a JavaScriptObject), then you're probably looking for somthing quite different: In that case you'd have to write a wrap() method like .google.gwt.user.client.ui.Button.wrap().

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745411229a4626542.html

相关推荐

  • java - cast JavaScriptObject to gwt widget - Stack Overflow

    may i know how to cast JavascriptObject get from JSNI into gwt as gwt CUstomWidgetCustomWiget widget =

    4小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信