ComboBox and ItemCaptionMode.ITEM

Hi,

I tried to use ComboBox with IndexedContainer and ItemCpationMode.ITEM. I wanted to use item’s toString method for showing texts into the combo box, but infortunatelly there is following code in the ComboBox:

protected List<?> getOptionsWithFilter(boolean needNullSelectOption) {
    Container container = getContainerDataSource();

    if (pageLength == 0 && !isFilteringNeeded()) {
        // no paging or filtering: return all items
        filteredSize = container.size();
        assert filteredSize >= 0;
        return new ArrayList<Object>(container.getItemIds());
    }

    if (!(container instanceof Filterable)
            || !(container instanceof Indexed)
            || getItemCaptionMode() != ITEM_CAPTION_MODE_PROPERTY) {
        return null;
    }

You can see, that if item caption mode is different from ITEM_CAPTION_MODE_PROPERTY combo returns null, while actually there are some items into the container. I found this strange as a behaviour and I rather prefer to see some items with empty captions and warning eventually instead of silently skiping combo box load.

Thanks

Hi,

I think the issue is somewhere else. See the following snippet from paintContent -method of ComboBox:

// first try if using container filters is possible
List<?> options = getOptionsWithFilter(nullOptionVisible);
if (null == options) {
    // not able to use container filters, perform explicit in-memory
   // filtering
    options = getFilteredOptions();
    filteredSize = options.size();
    options = sanitetizeList(options, nullOptionVisible);
}

So in short, it’s first just attempting to use container filters directly. If that fails (null result; this is what you’re seeing) the filtering will be done in-memory.

If possible, please post a simple test case showing what you’re doing. It will be easier to help you that way.

-tepi