5

I need to refresh the page in vaadin. I created a Refresh Button but the button is not working for refreshing the page.

Button Refresh = new Button("Refresh");
Refresh.addClickListener(new Button.ClickListener() {
    @Override
    public void buttonClick(Button.ClickEvent clickEvent) {
    }
});
Draken
  • 3,134
  • 13
  • 34
  • 54
dhS
  • 3,739
  • 5
  • 26
  • 55
  • What should happen in the `buttonClick()` method? – André Schild Sep 12 '16 at 07:10
  • @AndréSchild I have creadted a grid in the page i want the grid to refresh again without any changes(search results, sorting ). Buttonclick method should make the page as it was on it's first access. – dhS Sep 12 '16 at 07:26
  • Is it a GridLayout or a data grid? Possible duplicate of http://stackoverflow.com/questions/32275944/how-can-you-refresh-a-vaadin-grid-after-data-change and http://stackoverflow.com/questions/29204674/update-grid-with-a-fresh-set-of-data-in-vaadin-7-4-app – André Schild Sep 12 '16 at 07:57
  • In your code you've added a listener for the button, then a method that should do something when tie button is clicked... but the code for this method is empty :(. What do you expect to get if you haven't told him to do anything after the button is clicked? – Pere Nov 28 '17 at 08:45

2 Answers2

21

For Vaadin 10:

Call this in your Button ClickListener:

    UI.getCurrent().getPage().reload();
AndyW
  • 985
  • 3
  • 10
  • 21
11

Call this in your Button ClickListener:

Page.getCurrent().reload();

This reloads the page in the browser.

Axel Meier
  • 1,105
  • 2
  • 18
  • 28