Question

i have to develop a web application using Vaadin 7, and i have a function that store the data in the database and it should be executed just once when i run the project but not in every time i refresh the page. i try to write this function in the constructor like this:

 public class Dmav_3UI extends UI {
  public class Dmav_3UI extends UI {

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = Dmav_3UI.class)
    public static class Servlet extends VaadinServlet {
    }
    }
    public Dmav_3UI(){
            myFunction();

        }

but it still run every time i refresh the page. can you help me please?

Was it helpful?

Solution

Annotate the UI with @PreserveOnRefresh. The documentation states that unless this is used, a new UI instance is created on each page refresh.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top