开发者

cast JavaScriptObject to gwt widget

may i know how to cast JavascriptObject get from JSNI into gwt as gwt C开发者_运维百科UstomWidget

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


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.com/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 com.google.gwt.user.client.ui.Button.wrap().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜