How to add button to table using FieldFactory

Hi,
I am developing a table which has columns with multiple columns. One column should display a button. Following is my code. It does show the button but giving me an exception:


java.lang.IllegalArgumentException: Button only accepts Boolean values
	at com.vaadin.ui.Button.setInternalValue(Button.java:378)
	at com.vaadin.ui.AbstractField.setPropertyDataSource(AbstractField.java:600)
	at com.vaadin.ui.Table.getPropertyValue(Table.java:2690)
	at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1559)
	at com.vaadin.ui.Table.attach(Table.java:2811)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.Panel.attach(Panel.java:489)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.Panel.attach(Panel.java:489)
	at com.vaadin.ui.Window.setApplication(Window.java:913)
	at com.vaadin.Application.addWindow(Application.java:356)
	at com.vaadin.Application.setMainWindow(Application.java:668)
....

My Code:


package hello;

import java.util.Collection;

import com.vaadin.Application;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.ui.BaseFieldFactory;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Field;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Select;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

public class MyView extends Application implements ClickListener {

	IndexedContainer container;
	VerticalLayout resultList = new VerticalLayout();
	private Button showContent;
	private Button addRow;

	@Override
	public void init() {
		Window main = new Window("The Main Window");
		setMainWindow(main);
		Table table = new Table();

		// table.addGeneratedColumn("combination", new ValueColumnGenerator());

		table.setFieldFactory(new BaseFieldFactory() {

			@Override
			public Field createField(Container container, Object itemId,
					Object propertyId, Component uiContext) {
				String pid = (String) propertyId;
				if (pid.equals("first")) {
					Button field = new Button();
					return field;
				} else if (pid.equals("second")) {
					Select field = new Select();
					field.setImmediate(true);
					field.addItem("there");
					field.addItem("world");
					return field;
				} else {
					return null;
				}
			}
		});
		container = getContainer();
		table.setContainerDataSource(container);
		table.setEditable(true);
		table.setWriteThrough(true);
		table.setImmediate(true);
		main.addComponent(table);
		showContent = new Button("Show all content", this);
		addRow = new Button("Add row", this);
		main.addComponent(showContent);
		main.addComponent(addRow);
		main.addComponent(resultList);
	}

	public IndexedContainer getContainer() {

		IndexedContainer container = new IndexedContainer();
		container.addContainerProperty("first", String.class, null);
		container.addContainerProperty("second", String.class, null);
		Hello hello = new Hello();
		hello.setFirst("hello");
		hello.setSecond("there");
		Item item = container.addItem(hello);
		item.getItemProperty("first").setValue("testing fieldfactory");
		item.getItemProperty("second").setValue("there");
		return container;
	}

	public class Hello {

		public String first;
		public String second;

		public Hello() {
			first = "f";
			second = "l";
		}

		public String getFirst() {
			return first;
		}

		public void setFirst(String first) {
			this.first = first;
		}

		public String getSecond() {
			return second;
		}

		public void setSecond(String second) {
			this.second = second;
		}

	}

	/** Formats the value in a column containing Double objects. */
	class ValueColumnGenerator implements Table.ColumnGenerator {
		/**
		 * Generates the cell containing the Double value. The column is
		 * irrelevant in this use case.
		 */
		public Component generateCell(Table source, Object itemId,
				Object columnId) {
			Hello hello = (Hello) itemId;
			return new Label(hello.getFirst() + " " + hello.getSecond());
		}
	}

	public void buttonClick(ClickEvent event) {
		if (event.getButton() == showContent) {
			resultList.removeAllComponents();
			Collection<Hello> c = (Collection<Hello>) container.getItemIds();
			for (Hello hello : c) {
				HorizontalLayout hl = new HorizontalLayout();
				hl.addComponent(new Label(hello.getFirst()));
				hl.addComponent(new Label(hello.getSecond()));
				resultList.addComponent(hl);
			}
		} else if (event.getButton() == addRow) {
			Hello h = new Hello();
			Item i = container.addItem(h);
			// i.getItemProperty("first").setValue(h.getFirst());
			// i.getItemProperty("second").setValue(h.getSecond());

		}
	}

}

This is what I saw: