Drag&Drop between form components

Hi there,

I’m using vaadin 6 and I’m having trouble in using drag&drop feature with form’s components.

My use case is simple. I have a Form in which I add several textfields and I want to let the user change the order of the textfields using drag&drop.
I have seen in the demo (
http://demo.vaadin.com/sampler#DragDropRearrangeComponents
) an example but this one is adding components without using a form.


// I want to let the user to change the order of textfields:
Form form = new Form();
form.addField("name", new TextField("Name"));
form.addField("surname", new TextField("Surname"));

I don’t know how to add wrapped components and at the same time keep the form. If I try to add the whole form as a wrappedcomponent I can’t drag&drop its fields but if I add the textfields I don’t know how maintain the relationship with the form.

I know there is an addon with a d&d formLayout but what I need is quite simple and I think the demo is quite “near” to what I need but I don’t understand what I’m missing.

Thanks for any help.

Hi,

I think you can’t use the DragAndDropWrapper here since it’s not a Field, which is what the form will require. Have you tried adding the following after you instanciate your Form component:

form.setLayout(new DDFormLayout());

You will of course need to download and add the DragDropLayouts add-on to your project.