Hi,
I’m facing the following problem:
-
i have a comboxbox with a value change listener. When some option is selected the listener is invoked;
-
in this listener i set the value of some text area
-
after this, i modify the text in the text area and submit
-
after submit i commit the form and the listener of combobox is invoked again (the selected option in combobox was not modified) and replaced the modified text
How can i avoid this?
final ComboBox comboBox = new ComboBox(createCaptionByPropertyId(fieldName));
comboBox.setWidth("50%");
comboBox.setImmediate(true);
comboBox.setContainerDataSource(new MyElementsContainer(parent, "fullName"));
comboBox.setItemCaptionPropertyId("fullName");
comboBox.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
comboBox.setNullSelectionAllowed(false);
comboBox.addListener(new MyListener());
And the listener code is:
static private class MyListener implements Property.ValueChangeListener {
static private final long serialVersionUID = 1L;
private MyForm form;
private String fieldName;
public SelectFragmentoValueChangeListenter(final MyForm form, final String fieldName) {
this.form = form;
this.fieldName = fieldName;
}
@Override
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
if (event.getProperty() == null) {
return;
}
final Long selectedItem = Long.valueOf(event.getProperty().toString());
final Xpto element = Xpto.INFO.get(selectedItem);
// modify value with element text
form.getField(fieldName).setValue(element.getTexto());
}
}
After commit in the form, the listener is invoked and replacing all modifications …
Any ideias, how to avoid this?
Thanks,
Joao.