Editable Grid with BeanItemContainer and ComboBox with BeanItemContainer

As stated in the topic, I have an editable grid connected to a bean item container. My bean contains IDs of the values NOT the values themselves (I convert the value based on the user’s locale).

For the values to present, I need to show them as a comboxbox when the grid row is edited. I’ve tried creating a converter for these fields with the object type (KeyValue), but I get conversion errors. So I ripped that out.

Here’s my code:

SourceData container = new BeanItemContainer(SourceData.class,data);
Grid grid = new Grid(container);
grid.setImmediate(true);
grid.setColumns(VISIBLE_COLUMN_IDS);
grid.setEditorEnabled(true);
grid.setEditorBuffered(true);

ComboBox categoryField = new ComboBox();
categoryField.setImmediate(true); categoryField.setNullSelectionAllowed(false); categoryField.setItemCaptionPropertyId(“value”); categoryField.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); categoryField.setContainerDataSource(i18n.getCategories()); //BeanItemContainer

grid.getColumn(“dataCategory”).setEditorField(categoryField);

RESULT
Grid shows the data as KEY (as is saved in the database), not the VALUE from the ComboBox beanitemcontainer.
Editing the row, clicking on the combobox (twice), first value is empty, rest of combobox is as expected.

I’m at my wits end.
Help.

Sheila

If you have BeanItemContainer as data source for the ComboBox, the value of the ComboBox is a reference to selected object in the BeanItemContainer. Is this the logic you want to use?

Hi Tatu,

Thanks for getting back to me. Yes, you are correct - all of my comboxboxes are objects (key/value). To make the application internationalized, this is the only way to do it. In lieu of it working as a fully editable row, I’ve decided to use the DetailsGenerator instead. My wits are back now.

Thanks,
Sheila