admin管理员组

文章数量:1426072

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

本文标签: javacast JavaScriptObject to gwt widgetStack Overflow