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.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JavascriptComponent: detach()
Hi there,
I wrote a subclass of AbstractJavaScriptComponent and it's working nicely. Now the problem is that I need to call a destroy method when the component is detached. I tried this:
public void detach() {
callFunction("onDetach");
super.detach();
}
And in my js connector (...-connector.js) :
this.onDetach = function() { ...destroy code... }
But the method is not called. The detach() method on the server side is reached properly but the onDetach() method on the javascript side is not reached. It seems that "callFunction(...)" is not executed anymore because the component is being detached?!
Can anyone help me?
PS: I am using Vaadin 7.6.4
Hi Andrea,
in your javascript connector you can define the onUnregister function that will be called when component is detached;
the function is documented on 7.7 api but is available also on prevoius releases.
HTH
Marco