Reputation: 2712
I have a Widget with one Button and a DIV that should content dynamically generated Buttons in a <g:HTMLPanel></g:HTMLPanel>
.
How can i proceed so that by clicking on this Button GWT Buttons are created and added into that DIV?
Upvotes: 1
Views: 2061
Reputation: 312
Alternative to the answer already given:
<g:HTMLPanel ui:field="buttonPanel"></g:HTMLPanel>
Then, in your code, declare the panel as follows:
@UiField HTMLPanel buttonPanel;
And add your button like this:
buttonPanel.add(myButton);
Upvotes: 2
Reputation: 121998
Give id to the div in the binder like
<div id='dynamicDiv'></div>
And in your code add elements as below
RootPanel.get("dynamicDiv").add(myButton1);
RootPanel.get("dynamicDiv").add(myButton2);
Make sure that the dynamicDiv
is already added to the DOM
before you adding your buttons .
Upvotes: 1