Reload / refresh

Hello,

I have a problem refreshing my application. When I leave and then come back on my page, I should be able to detect it and relaod my pages. Do you have an idea how to do that?

Best regards

Try adding ?debug to the end of your url.

It will give you a box with a “restart app” button that does exactly what you want.

See Book of Vaadin section 12.4.1

I wish they had made this a bit more obvious, this made me nuts!

Hello,

I know its old thread but I have similary problem. I want to restart my application when I change value in combobox. I know only one solution:

invoking:
getApplication().start(new URL(getApplication().getURL() + “?restartApplication”), destProperties, getApplication().getContext());

but it doesnt work.

In ?debug mode there is a ‘Restart app’ button that works but I dont know what is he doing. Can anybody help me?

Thx,
Grzesiek D

I think you can just use getApplication().close() to restart the application

Thanks for answer.

Yes event if I close app, then what next? I need to start my application and getApplication.start (…) doesn’t work.
I need exactly functionality of “Restart app” button in Debug mode.

Directly from web browser URL: “/?restartApplication” does what i want but not with start() method. I’m working in OSGi environment (ServiceMix)…maybe here is a problem?

I was tracing HTTP session in this two cases and there is following different (on server side):

  1. invoking directly from browser:
  • POST (server URL)/UIDL?windowName=1&onloadburst=1
  • GET (server URL)/?restartApplication

and then requests for widgets and repainting

  1. invoking form application:
  • POST (server URL)/UIDL?windowName=1

and its all, in this case there is not sending GET request. Why? What is “onloadburst” parameter?

Thanks in advance,
Grzesiek D

The on
un
loadburst parameter indicates to the server that this is the last synchronous request the client is making to try to save all unsaved changes when the user closes a browser window or otherwise leaves the application page. It is triggered primarily from VView.onWindowClosing().


Henri Sara:

Thanks Henri,

It was good idea to look at the VView class but not by onWindowClosing() method only by another:

    /**
     * Used to reload host page on theme changes.
     */
    public static native void reloadHostPage()
    /*-{
         $wnd.location.reload();
     }-*/;

This method is invoking every time on theme change. So when I change theme of my application then application is restarting correctly! Every labels/fileds and titles are refreshing and changing language (i’m using this to internationalization).

Unfortunately i can’t invoke this native method myself…;(
Summary, from this three methods to restarting my app, works fine only number 3:

  1. getApplication().close();
    getApplication().start(new URL(getApplication().getURL() + “?restartApplication”), destProperties, getApplication().getContext());

  2. getWindow().executeJavaScript(“wnd.location.reload(true);”);

  3. if (getApplication().getTheme().equals(“my_theme”))
    getApplication().setTheme(“runo”);

I know it’s very strange method for restarting so pls, maybe someone knows how to invoke number 2 directly?

Grzesiek D

“Page.getCurrent().reload();” ? (without the quotes and question mark )

1)when i reload the current page in browser it go back to login page?
what i need is : when i reload page it should be in same page…

2)when i press back button it moves to login page in browser ?
what i need is :when i press back button it go back to previous page not login page…

Add @PreserveOnRefresh to your UI class (more info about it in the Book of Vaadin or just google it)

thanks for reply…
without using @preserve OnRefresh it is possible in vaadin…