ComboBox with newItemHandler. newItemHandler is never being called.

I am new to vaadin so i am probably doing something silly, but i have setup a page that has a comboBox in it that i want to be able to have the user either select/type an existing value or add a new value by typing something that doesn’t exist.

I am finding that the addINewItem method is never being called when i type a new value and press enter.

This is the code that i am using.


					serverEnvironmentEntry.setNullSelectionAllowed(false);
					serverEnvironmentEntry.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_EXPLICIT);
					for (Environment e : account.getEnvironments()) {
						serverEnvironmentEntry.addItem(e.getEnvironmentId());
						serverEnvironmentEntry.setItemCaption(e.getEnvironmentId(), e.getName());
						if (id != -1) {
							if (se.getEnvironment().getEnvironmentId().equals(e.getEnvironmentId())) {
								serverEnvironmentEntry.select(e.getEnvironmentId());
							}
						}
					}
					if (id == -1) {
						serverIdLable.setValue("New");
						serverEnabledEntry.setValue(true);
						serverNameEntry.setValue("");
						serverEnvironmentEntry.setNewItemsAllowed(true);
						serverEnvironmentEntry.setNewItemHandler(new AbstractSelect.NewItemHandler() {
	
							private static final long	serialVersionUID	= 9072125882244484624L;
	
							@Override
							public void addNewItem(String newItemCaption) {
								boolean updated = false;
								for (Object o : serverEnvironmentEntry.getItemIds()) {
									if (((Integer) o).intValue() == -1) {
										serverEnvironmentEntry.setItemCaption(-1, newItemCaption);
										updated = true;
										if (LOG.isDebugEnabled()) {
											LOG.debug("Updating new item with " + newItemCaption);
										}
										serverEnvironmentEntry.select(-1);
										break;
									}
								}
								if (!updated) {
									serverEnvironmentEntry.addItem(-1);
									serverEnvironmentEntry.setItemCaption(-1, newItemCaption);
									if (LOG.isDebugEnabled()) {
										LOG.debug("Adding new item with " + newItemCaption);
									}
									serverEnvironmentEntry.select(-1);
								}
							}
						});

I really don’t want to have to add a new field just to add a new item to the list. Any help would be appreciated.

Just guessing but have you tried to set your ComboBox immediate:

combobox.setImmediate(true);