最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - cast JavaScriptObject to gwt widget - Stack Overflow

programmeradmin1浏览0评论

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().

发布评论

评论列表(0)

  1. 暂无评论