ComboBox in editable table


I am trying to modify the example from the Book of Vaadin to make the table editable (
). I have setEditable(true) in and modified the field factory method to create a new combo for each row. The problem is that the combos do not show the value from the database, they are blank. The combo gets populated with the cities, and the correct city is selected (I have verified this with a debug method fired on a click event) but the value isn’t shown.

I saw on this forum that
had this problem too and the solution was to implement hashCode() and equals() but they were working with BeanContainers not SQLContainers.

The original example was showing a form below the table and in that form the combo was simply setting its value with select(), no hashCode, no equals. And the first attempt was to use the same code to generate each combo in the field factory, but it did not work. What can be wrong?

setTableFieldFactory(new DefaultFieldFactory() {
			public Field createField(Container container, Object itemId,
					Object propertyId, Component uiContext) {

				Field field;
				if (propertyId.equals("cityId")) {
					ComboBox city = getACityCombo();
					if (getItem(itemId).getItemProperty("cityId").getValue() != null) {
						int cityId = (Integer) getItem(itemId).getItemProperty(
					field = city;
				} else {
					field = super.createField(container, itemId, propertyId,

				return field;


	private ComboBox getACityCombo() {
		ComboBox cities = new ComboBox();


		return cities;

At least you shouldn’t set value of the ComboBox in the TableFieldFactory, because the Table does the data binding.

Also make sure the app.getDbHelp().getCityContainer() returns Items with id compatible with “cityId” value in this case Integer.

Thanks for the quick reply.

Well, at first I didn’t, but when I saw the combo problem I tried that, among other things…

The items returned are OK. I also made this debug method which should set the combo to the first element when a row is clicked. The combo is updated since I see it’s value in the form from the original demo, but the value still isn’t displayed in the combo.

addListener(new ItemClickListener() {
	public void itemClick(ItemClickEvent event) {

What else could it be?

I had a similar situation and until I don’t remove server (tomcat 7 in my case) from Eclipse and add new from scratch, combobox was not showing value.
Before that I was restarting server and adding ?restartApplication but without success.
Try it maybe will work for you too.

I removed and added the server again like you said, but it didn’t work for me :(…