Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

init(VaadinRequest request) method is call twice

Cesar Quinteiro Rendo
7 years ago Sep 14, 2015 11:19am

I am using Vaadin 7.5.5 , In a simple project If I put a break point in the debuger in the "protected void init(VaadinRequest request) "  method then stops there twice, I got a System.out.println(" INIT  " + new Date()); that is fire 2 times, If i take out the breakpoint then only fires once.

In another more complex project this happends also in runmode (not debug) when in the init calls a method that fills data from a mail service, then is also call twice.
the problem is that I am using some variables that determine what was the last data I read, and as in the first time that goes thru init , that variable is fill it, then the second time I get not data is that what finally is show in the container, then dependeing in how fast is resonding the service I got data or not.

It seems thats if Init(VaadinRequest request) doesn't finnish quick enough his inside methods, then is call it again, How can i avoid this?  

Johannes Häyry
7 years ago Sep 16, 2015 2:28pm
Cesar Quinteiro Rendo
7 years ago Sep 16, 2015 4:06pm

And what generates another session? If that is the case. I have only one browser (safari by example) open.  I do:
1) start tomcat and way until says "INFORMACIÓN: Server startup in 9325 ms" 
2) After a few seconds (checking that not ouput in console) I enter the URL in the browser and press enter
3) I get the following output.( 2 INIT with just one second between them)

it seems there is 2 sessions a least this is what I get with :

protected void init(VaadinRequest request) { 
        idAgent = request.getParameter("idAgent");
        idRole = getRole(idAgent);

System.out.println("INIT "+ new Date().toString() +" idAgent "+ idAgent + " idRole " + idRole + " session "+ request.getWrappedSession());
..........
 

Print OUT --->
INIT Wed Sep 16 17:55:13 CEST 2015 idAgent 5 idRole 0 session com.vaadin.server.WrappedHttpSession@3822c1c5
INIT Wed Sep 16 17:55:14 CEST 2015 idAgent 5 idRole 0 session com.vaadin.server.WrappedHttpSession@36a0a0a9