Hello everybody
This is my Problem with Vaadin 7.6.3
I have a Grid, with a Beancontainer source and bind the selected grid row with a beanfieldgroup to
textfields and a Combobox.
Now, if you have a field in the grid equal “CC/44”, and this field has been bound with the Combobox,
and the Dropdownlist has the same string “CC/44”, the combobox refresh fail after the second
click to this grid row.
Do I something wrong, or is this a combobox bug?
Please take the sample code below and check it out.
Thank you very much.
public class MyUI extends UI {
final BeanContainer<String, Person> personBeanContainer = new BeanContainer<>(Person.class);
// Bind forms to beans and manage validation and buffering
BeanFieldGroup<Person> formFieldBindings;
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
final TextField name = new TextField("Name:");
final TextField born = new TextField("Born:");
final ComboBox testCombo = new ComboBox("Test:");
personBeanContainer.setBeanIdProperty("name");
// Put some example data in it
personBeanContainer.addBean(new Person("Nicolaus Copernicus", "1543", "W5"));
personBeanContainer.addBean(new Person("Galileo Galilei", "1564", "CC/44")); // String with slash
personBeanContainer.addBean(new Person("Johannes Kepler", "1571", "Q10"));
// Add some items with a given ID
testCombo.addItem("A5");
testCombo.addItem("CC/44"); // Same slash String in the Dropdown List --> Combobox refresh fail
testCombo.addItem("Z1");
// Create a grid
Grid grid = new Grid();
grid.setContainerDataSource(personBeanContainer);
grid.addSelectionListener(event -> {
BeanItem<Person>item = personBeanContainer.getItem(grid.getSelectedRow());
formFieldBindings = BeanFieldGroup.bindFieldsBuffered(item.getBean(), this);
formFieldBindings.bind(testCombo, "test");
formFieldBindings.bind(name, "name");
formFieldBindings.bind(born, "born");
});
HorizontalLayout hLayout = new HorizontalLayout(grid, new FormLayout(name, born, testCombo));
hLayout.setMargin(true);
hLayout.setSpacing(true);
layout.addComponent(hLayout);
setContent(layout);
}
public class Person implements Serializable {
String name;
String born;
String test;
public Person(String name, String born, String test) {
this.name = name;
this.born = born;
this.test = test;
}
public String getName() {
return name;
}
public String getBorn() {
return born;
}
public String getTest() {
return test;
}
public void setName(String name) {
this.name = name;
}
public void setBorn(String born) {
this.born = born;
}
public void setTest(String test) {
this.test = test;
}
}
@WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
public static class MyUIServlet extends VaadinServlet {
}
}