Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Dynamicly add fields to a form
As a newby in Vaadin (I started development with vaadin two weeks ago), all the vaadin concepts are already quiet new for me. Most of the things worked fine so far. The first thing I found no appropriate documentation for is the more advanced form handling in vaadin.
I'm now about to create a user creation form which should contain the ability add multiple e-mail aliases. For this I should have the possibility to add a button which adds a new textfield to the form (at a specific location) in which the admin can add addtional e-mail aliases for the user. The simple form demo and the advanced layout form demo had no sample code which would give me an idea how to implement such a feature.
Can someone give me hint how to implement a such feature in vaadin?
Its ab it irritating to read no answer at all. Is the question that dump or is it impossbile to using the form layout for a such function?
Dit you try form.addField(), form.getLayout().addComponent()?
Yea, but I have to add the new field to a specific location within the form.
Sorry, the question was not fully clear in that point.
The method form.getLayout().addComponent() adds the component at the end of the form. But the (initial) e-mail alias field is somewhere in the middle of the form.
The new alias field should be below that field and not at the end of the whole form.
You can add at a certain index:
FormLayout layout = (FormLayout)form.getLayout(); layout.addComponent(emailField, index);