How do I convert GWT Query to widget?

680 views Asked by At

I just started working with GWT Widgets. I am familiar with jQuery and GWT Query is similar and hence I'm comfortable with it.

I need to make a custom widget in GWT which encompasses the functionality I made in GQuery.

I know that GWT widgets need to be contained in a panel, but I have an existing element in GQuery. So I guess I need to convert that element to a widget first. How should I go about it ?

2

There are 2 answers

1
Manolo Carrasco Moñino On

Using last code in GQuery (1.2.1-SNAPSHOT), you should be able to convert any element into a gwt panel using the panel() method.

GQuery myGQueryWidget = $("<div><h1>Hello</h1>World</div>");
Panel myGwtWidget = myGQueryWidget.as(Widgets.Widgets).panel();

Of course you can use this panel as any widget which you can add to any other gwt panel, or even you could add other gwt widgets to it.

You have to be aware about events because if you add gwt events to the panel it will remove events added with gquery

0
Stefan On

you can use GWTQuerys WidgetsHtmlPanel(http://gwtquery.googlecode.com/svn/trunk/gwtquery-core/javadoc/com/google/gwt/query/client/plugins/widgets/WidgetsHtmlPanel.html ) to convert HTML content to Panel.

This should do the trick.