views:

44

answers:

1

Basically I have a page with a button and listbox on it. When the button is clicked, I use a ClickHandler to add another item to the listbox. However, the listbox is not refreshed unless I use the browser refresh button. Is there a way to do this programmatically without refreshing the entire Window?

Thank you

A: 

The following code works for me without any manual refresh (tested on Firefox 3.6.12 and Safari 5.0.2 with GWT 2.0.3):

public void onModuleLoad() {

    final RootPanel rootPanel = RootPanel.get();

    final ListBox listBox = new ListBox();
    listBox.addItem("Alpha");
    rootPanel.add(listBox);

    final Button button = new Button("Button");
    button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            listBox.addItem("Beta");
        }
    });
    rootPanel.add(button);

}

Please test, if my code works for you, too. Is there something special about your code (or maybe you're using a different browser that behaves differently?)

Chris Lercher