Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Dynamically update form according to inputted data
I'm trying to implement dynamic form: when user selects some value from a Select field, some new fileds should be added to the current form.
To achieve this I've implemented FormFieldFactory which makes those extra fields not visible and I've tried to add listener to the Select field which makes required field visible.
I've added ValueChangeListener the way like this:
field.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
if (UserType.NEWCOMER.equals(event.getProperty().getValue())) {
form.getField(SOMEFIELD).setVisible(true);
} else {
form.getField(SOMEFIELD).setVisible(false);
}
}
});
But the ValueChangeEvent fires up when user actually clicks on the Select field, not when he selects value, so it makes user to click on the Select field twice (after the first click there no value in the corresponding property so listener does nothing).
What am I doing wrong?
Thanks a lot!
This helped:
field.setImmediate(true);