Cannot add new item to ComboBox

I want to use a ComboBox to input time-of-day. The data model in a bean is of type LocalTime from the joda library with getter and setter.
The conversion LocalTime<->String is done by a Converter.
The ComboBox should list some default values (08:00, 08:30, 09:00) but also allow the user to input any valid time (eg. 08:45). The ComboBox has setNewItemsAllowed(true)
When I type in a new value, as soon as the ComboBox loses focus it takes again the last value. The new item handler is not called.

What am I doing wrong?

Full working code showing the problem:

import java.util.Arrays;
import java.util.Locale;

import org.joda.time.LocalTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.data.util.BeanItem;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.VerticalLayout;

public class TestTab extends VerticalLayout {
  private static final Logger logger = LoggerFactory.getLogger(TestTab.class);
  
  private ComboBox startTime = new ComboBox("Begin: ", Arrays.asList("08:00","08:30","09:00"));
  private Converter<Object, LocalTime> converter = new LocalTimeConverter();

  public TestTab() {
    BeanItem<TestBean> item = new BeanItem<TestTab.TestBean>(new TestBean());
    FieldGroup fg = new FieldGroup();
    fg.setItemDataSource(item);

    
    startTime.setNullSelectionAllowed(false);
    startTime.setNewItemsAllowed(true);
    startTime.setConverter(converter);
    addComponent(startTime);
    fg.bind(startTime, "time");
  }
  
  public static class TestBean {
    private LocalTime time = new LocalTime(8,30);

    public LocalTime getTime() {
      logger.debug("Getting Time " + time);
      return time;
    }

    public void setTime(LocalTime time) {
      logger.debug("Setting Time " + time);
      this.time = time;
    }
  }
  
  
  public static class LocalTimeConverter implements Converter<Object, LocalTime> {
    @Override
    public LocalTime convertToModel(Object value, Class<? extends LocalTime> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
      logger.debug("Converting to model: " + value);
      return LocalTime.parse((String)value);
    }

    @Override
    public Object convertToPresentation(LocalTime value, Class<? extends Object> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
      logger.debug("Converting to presentation: " + value);
      return ((LocalTime)value).toString("HH:mm");
    }
    
    @Override
    public Class getModelType() {
      return LocalTime.class;
    }

    @Override
    public Class getPresentationType() {
      return String.class;
    }
  }
}

You say that the NewItemHandler isn’t called, but you haven’t posted the code for it. Here is a snippet I use in a project:

        final ComboBox producer = new ComboBox("Producer");
        producer.setImmediate(true);
        producer.addItems(presenter.getProducers());
        producer.setNewItemsAllowed(true);
        producer.setNewItemHandler(new NewItemHandler() {
            
            @Override
            public void addNewItem(String newItemCaption) {
                producer.addItem(newItemCaption);
                producer.select(newItemCaption);
            }
        });

I tested with a dummy new item handler with just a log statement in it, and never saw the corresponding log - so concluded that the handler is not called.
Also, as far as I understand, the default new item handle should be just fine for my case (only string value).

Just a thought: is the CB in immediate mode?

Thanks for the suggestion. In my example code, I guess it isn’t. Should it be, to allow adding values?
Will try it out and report back. (but out of office until 1st sept. - so after that)

Thanks! Setting in immediate mode solved the problem - now new items can be added!