Hi I have the same problem and it was driving me crazy, I’m working with vaadin 7, so I don’t know if this works with vaadin 6, but the problem was that I was creating a FieldGroup as a BeanFieldGroup and setting a bean with no values on it.
So the FieldGroup shows the values of my bean no the values that I set while I was creating the layout.
Here’s how i was creating my field group:
fieldGroup = new BeanFieldGroup<UserBean>(UserBean.class);
form = new AddUserForm(); // This is a layout with controls on it
form.setRoleItems(vm.getRoles()); // I fill the combo box
contentPanelLayout.addComponent(form);
fieldGroup.bind(form.getUserName(), "name");
fieldGroup.bind(form.getUserPassword(), "password");
fieldGroup.bind(form.getUserRePassword(), "repassword");
fieldGroup.bind(form.getEmail(), "email");
fieldGroup.bind(form.getSecret(), "secret");
fieldGroup.bind(form.getAnswer(), "answer");
fieldGroup.bind(form.getRol(), "idRol"); // this is the combo box
Here’s how I fill my combobox
/**
* Set's the role items that are going to be display in the combo box role so it can be
* selected by the user
* @param roles List of PlatformRole to fill the combo box roles
*/
public void setRoleItems(List<PlatformRole> roles) {
for (PlatformRole platformRole : roles) {
rol.addItem(platformRole.getId());
rol.setItemCaption(platformRole.getId(), platformRole.getDescription());
}
rol.setImmediate(true);
rol.setNullSelectionAllowed(false);
// if (roles.size() > 0)
// {
// if (rol.getValue() == null) {
// rol.setValue(rol.getItemIds().iterator().next());
// }
// } // This piece of code was working OK but I remove it because it doesn't matter
}
And here’s my problem
fieldGroup.setItemDataSource(new BeanItem<UserBean>(new UserBean()));
So I change it with this and it works now
fieldGroup.setItemDataSource(new BeanItem<UserBean>(new UserBean(0,"","","","","","",1)));
I didn’t realize that the FieldGroup set the value of the controls, so I guess it was my mistake not check the docs