public void onAttachOrDetach(AttachEvent event) { if (!event.isAttached()) { // on detach if (event.getSource() instanceof HasAllDragAndDropHandlers) { // clean up from handlerRegistrationsMap to avoid // potential memory leak: removePreviousHandlers((HasAllDragAndDropHandlers) event.getSource()); } } } }