First entry is empty in ComboBox (AbstractSelect)

Hi there,

I don’t know how to get rid of the first empty row in my ComboBox (select). Here is a simplified version of the code:

private static <T> AbstractSelect fillData(List<T> list, Class selectType, String displayMemeber){
       AbstractSelect select = null;
       if(selectType.equals(NativeSelect.class))
              select = new NativeSelect("");
       else if(selectType.equals(OptionGroup.class))
              select = new OptionGroup("");
       else if(selectType.equals(ListSelect.class))
              select = new ListSelect("");
       else if(selectType.equals(Select.class))
              select = new Select("");
       else if(selectType.equals(Table.class))
              select = new Table("");
       else if(selectType.equals(Tree.class))
              select = new Tree("");
       if(list != null && list.size() > 0){
              BeanItemContainer<T> param = 
                      new BeanItemContainer<T>(list);
              select.setContainerDataSource(param);
              select.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
              select.setItemCaptionPropertyId(displayMemeber);
       }
       return select;
}

The idea of the method is to make a combobox when given 1. the type of the combobox, 2. data source as a list of objects and 3. the property name of the object to be displayed. Eg:

List custList = XXXX; // get customers
ListSelect lstCustomer = fillData.(custList, ListSelect.class, “name”);

The above code will create a list box with all customer objects and customer name as the display member. However when I use this method, the first entry is always empty. i put break point and checked, I binded a list of 3 elements to a ListSelect, but it display 4 items where the first item is empty. Any idea?

Br,
Xuan

Try setting nullSelectionAllowed to false, and selecting the first item.