How to set DragImageComponent in DragAndDropWrapper in Vaadin 8.0.6 while c

I am trying to do some drag and drop in Vaadin 8.0.6. I want to show another component instead of the dragged component during dragging. In documentation I found that I can use a code like this:

DragAndDropWrapper draggable = new DragAndDropWrapper(draggableComponent); Label label = new Label(“test”); draggable.setDragImageComponent(label); draggable.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT_OTHER);
the problem is that the label should have an connectorId other wise I am getting this error: “Component must be attached to a session when getConnectorId() is called for the first time”);So the component should be presented somewhere in GUI if I want to use this. And actually if I use an already created component this is working. But I don’t want to show DragImageComponent’s in GUI. I tried to hide them by using setVisible but then Vaadin will show the actual drag source component instead of DragImageComponent. Below is simple test class showing what I tried to achieve:

Layout formLayout = new FormLayout();
Button dragSource = new Button(“This is a button!”);
DragAndDropWrapper draggable = new DragAndDropWrapper(dragSource);
Label dragImage = new Label(“This is a label”);
draggable.setDragImageComponent(dragImage); draggable.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT_OTHER); formLayout.addComponents(draggable, dragImage); setCompositionRoot(formLayout);

Is this possible in Vaadin? Any idea?

The API documentation is bit limited here (and I’m probably the one to blame). IIRC (I was implementing this years ago) the other component must be attached and visible in the browser. IIRC, there is no way to specify an arbitrary image or component as drag image.


With the new drag and drop support in Vaadin Framework 8.1, you can specify an arbitrary drag image, but not a separate drag image component.