if the brower close the vaddin UI page,the server-side how to listen the cl

Do the listener exist which listen the browser close event that can instantly know the UI has closed and then release the resource?

DetachListener should be work in your case;
https://vaadin.com/docs/v10/flow/advanced/tutorial-application-lifecycle.html

Gabriel Pedro:
DetachListener should be work in your case;
https://vaadin.com/docs/v10/flow/advanced/tutorial-application-lifecycle.html

thanks,but when I use this method in the UI init(),for instance this.addDetachListener(),what I expected is when I close the UI page and wait 3 heartbeats then detach() can instantly be called ,but actually I found the method was not called util I open an new UI page again.How to called the method immidiately just the 3 heartbeats gone?

guo zhichen:

Gabriel Pedro:
DetachListener should be work in your case;
https://vaadin.com/docs/v10/flow/advanced/tutorial-application-lifecycle.html

thanks,but when I use this method in the UI init(),for instance this.addDetachListener(),what I expected is when I close the UI page and wait 3 heartbeats then detach() can instantly be called ,but actually I found the method was not called util I open an new UI page again.How to called the method immidiately just the 3 heartbeats gone?

Following the documentation, it simply implements SessionDestroyListener on VaadinServlet.

Read the topics:

  • Session Expiration
  • Handling Session Initialization and Destruction

https://vaadin.com/docs/v10/flow/advanced/tutorial-application-lifecycle.html

Gabriel Pedro:

guo zhichen:

Gabriel Pedro:
DetachListener should be work in your case;
https://vaadin.com/docs/v10/flow/advanced/tutorial-application-lifecycle.html

thanks,but when I use this method in the UI init(),for instance this.addDetachListener(),what I expected is when I close the UI page and wait 3 heartbeats then detach() can instantly be called ,but actually I found the method was not called util I open an new UI page again.How to called the method immidiately just the 3 heartbeats gone?

Following the documentation, it simply implements SessionDestroyListener on VaadinServlet.

Read the topics:

  • Session Expiration
  • Handling Session Initialization and Destruction

https://vaadin.com/docs/v10/flow/advanced/tutorial-application-lifecycle.html

thanks ,actually I’m using the vaadin 8 intergrated with spring ,so I using the @SpirngUI(“/”) instead of vaadinServlet ,so I’m not sure where can I add SessionDestroyListener . Besides, I feel greateful for you help.

Extending SpringVaadinServletannotated with@Component(“vaadinServlet”)` should be work.

Reference: https://stackoverflow.com/a/33035981

please do not be inconvenient by creating several topics.

I have delete it.thanks for you patient help.

I’ve try it ,but it doesn’t work ,may be I can find another way to solve it.