Arnaud Denoyelle
Arnaud Denoyelle

Reputation: 31283

Generic way to convert Element to Widget

I created a component which root element is a com.google.gwt.dom.client.Element

Element select=DOM.createSelect();
...

Now, I would like this Element to be a Widget. How do I do that?

Until now, the only way I found is:

Element select=DOM.createSelect();
...
FlowPanel div=new FlowPanel(); //This will become a <div> tag.
div.getElement().appendChild(select.getElement());
return div;

but this causes my <select> to be wrapped in a <div>. Is there a way to make the Element be a widget without having it wrapped into a <div> ?

Upvotes: 2

Views: 2236

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64561

How about extending Widget and providing the element to setElement? This is how widgets are built (have a look at the code of ListBox for an example that uses a <select>)

Upvotes: 7

Related Questions