WHY: new instance of client connector on every attach?

Hey,

THE QUESTION:
let’s say you use a server-side component, then you remove it from the DOM (e.g. when using a custom tabsheet implementation and another tab is selected) and then you try to attach it again (its corresponding tab being selected again). From what I observed, Vaadin unregisters the client connectors when detaching and as a result creates a whole new series of connectors and widgets when reattaching. Why is it implemented like this? To enable garbage-collection for the unregistered objects and because later there’s no telling whether they have really been garbage-collected?

THE PROBLEM:
The mentioned detached/reattached component contains a few HTML5 canvas elements which are used for drawing by KineticJS. This is all client-exclusive and obviously, none of the drawn stuff is serialized to the server (nor it should be) so when I issue a detach command from the server, the content is (without a special preserving mechanism) lost.
I tried to work it around with outsourcing the client widgets (using connector ids as references) but:

  • Vaadin then complains the widgets have not been removed from the DOM (despite “widget.removeFromParent()” being called) and even suggests a link to the widget’s previous connector (its id).
  • Connector ids are not yet known when the method “createWidget()” on the connector is called.

SOLUTION?
I think I might eventually succeed in bypassing all this somehow but the question is: is there a smarter way? Hiding (instead of removing from DOM) could be one of them but I’d prefer for Vaadin to resolve this, if possible. I may be wrong because I don’t know the details of Vaadin architecture, but imho a functionality like “detach but don’t lose it just yet” should be present in Vaadin :). At the very least, it should boost performance a bit.