How to transform elements to widgets?

78 views Asked by At

I'm working on a GWT website generated with elements:

DivElement footerElement = Document.get().createDivElement();
footerElement.setAttribute("id", "mainFooter");

HeadingElement headingElement = Document.get().createHElement(2);
headingElement.setInnerText("This is a footer block");

RootPanel.get().add(footerElement );

I want to test some layout panels disposals, but I read that I can only add widgets to layout panels.

Are they some way to transform my elements into widgets without write again all my IHM?

1

There are 1 answers

1
francesco foresti On BEST ANSWER

try with something like

FlowPanel panel = new FlowPanel();
HTML wrap = new HTML().wrap(myElement);
panel.add(wrap);
RootPanel.get().add(panel);

note : the FlowPanel is not strictly necessary. It adds a <div> around your elements (and HTML.wrap() will add one too). A panel could be helpful if you want to group elements/widgets together.