I am trying to understand the life cycle of Vaadin Flow applications. (I need this to think about some workaround for handling page reload).
I just added a Servlet and UI to the standard test application.
When I start the application from the IDE (I’m use IntelliJ IDEA with Jetty), UI is constructed 3 times. Every time I do a reload of the page, UI is getting created 2 times. Why it has to be like this?
package com.habibbank.syam;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.router.Route;
@Route("")
public class MainView extends Div {
public MainView() {
Button button = new Button("Click me", event -> Notification.show("Clicked!"));
add(button);
}
}
I did the same but I am always getting “UI created” 3 times when the URL is opened for the first time and “UI created” 2 times whenever I refreshed it!!
I have the same pom.xml generated by the vaadin/starter with absolutely no changes!
What could be the possibilities for such a behaviour? Any clues?
This is happening in Chrome and it works as properly in Firefox. (I am using Linux and I don’t have access to other browsers now, so not tested on other browsers).
I was accessing the application via localhost and Chrome doesn’t store cookies for localhost (It doesn’t store cookies if the domain doesn’t contain any dots). So, without cookies, Vaadin Flow was not able to keep track of the sessions properly.
The workaround is to use 0.0.0.0 or the local IP address while testing it in Chrome.