File Upload and Display

I tried to change the sample code for the drag and drop sample, so that instead of showing the uploaded image in a new window it would replace the drop target with the image. However, it gives me an error simply adding the (Embedded) component to the DragDropHtml5… object.

How could I go about doing that?

Joel

Here’s the code. The commented out code works, the one line I added does not. I’m sure I’m doing something “obviously” wrong, just curious what it is.

I get an UnsupportedOperation Exception.

    private void showComponent(Component c, String name) {

// VerticalLayout layout = new VerticalLayout();
// layout.setSizeUndefined();
// layout.setMargin(true);
// Window w = new Window(name, layout);
// w.setSizeUndefined();
// c.setSizeUndefined();
// w.addComponent(c);
// getWindow().addWindow(w);
addComponent(c);
}

J

The “this” object there is a DragAndDropWrapper, which extends CustomComponent. It doesn’t support addComponent(). You could try setCompositionRoot(), but I don’t really know what your application is like, so that may or may not do what you intend.