Editable Table using JPAContainer and ComboBox

Hi all,

I am relatively new to Vaadin and trying to build an application to match a legacy application. I have to replicate features in it and am having a problem with one.

I want to provide an editable table where the foriegn key columns are a drop down list comprised of a list of options ( pulled from the database ). I created a custom TableFieldFactory and the combobox is displayed and populated, but I can’t get the current value to display in the row. The screenshot is what I am seeing.


Below is the code for the TableFieldFactory

[code]
@Component
public class StoreTableFieldFactory implements TableFieldFactory {

@Autowired
private EntityManagerFactory entityManagerFactory;
private final static Logger logger = LoggerFactory.getLogger(StoreTableFieldFactory.class);

@Override
public Field<?> createField(Container container, Object itemId, 

Object propertyId, com.vaadin.ui.Component uiContext) {

    Item item = container.getItem(itemId);
    Property<?> property = item.getItemProperty(propertyId);

    if(property.getValue() instanceof Store ){
        final ComboBox storeSelector = new ComboBox();

        JPAContainer<Store> storeContainer ;
        storeContainer = JPAContainerFactory.make(Store.class,

entityManagerFactory.createEntityManager());
storeSelector.setContainerDataSource(storeContainer);
storeSelector.setItemCaptionMode(ItemCaptionMode.PROPERTY);
storeSelector.setItemCaptionPropertyId(“name”);
storeSelector.setNullSelectionAllowed(false);
storeSelector.setImmediate(true);

        return storeSelector;
    }

    return DefaultFieldFactory.get().createField(container, itemId, propertyId,uiContext);
}

}
[/code]I tried the ComboBox.SetValue in the createField method, but that does nothing. Is there any examples of using CombBoxes as an editable column out there I can use? I have searched high and low and I can’t fnd anyting that works. Thanks for your time.

Found the answer here:
https://vaadin.com/forum#!/thread/2729098

Added one line of code and it works now:
storeSelector.setConverter(new SingleSelectConverter(storeSelector));

Hi Mel
I am new in vaadin. Noticed that the coponents in the table are not resized when the column width is changed. Any tips to resize them automatically?