Why is drag/dropped component null?


I have implemented Drag and Drop in my app. Sometimes the source component is null.

 DragAndDropWrapper dropTarget = new DragAndDropWrapper(...);
        dropTarget.setDropHandler(new DropHandler() {
            public void drop(DragAndDropEvent event) {
                  Component source = event.getTransferable().getSourceComponent(); // sometimes this is null

How can the source component be null?


I have come across the same problem when the dragged component is a complex object (that is, not a simple Label, for instance).

I figured this out. Dragging and dropping a component fires a server-side event. This event takes some time to process. While it’s being processed, the user starts dragging another component. The server finishes the event execution and rebuilds the portion of the page that contains the source drag components. The user drops the component on the target, but the source component no longer exists on the server because the collection was rebuilt.

I’ve started another thread regarding multiple concurrent events.