Search code examples
gwtuibinder

How to dynamically create GWT UIBinder Element?


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?


Solution

  • 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);