Simple Table Widget Initilization

To start with I want to create a simple widget containing a static table.
I’ve written the following code:


public class MyfirstwidgetApplication extends Application {
	private static final long serialVersionUID = 1L;

	public void init() {
		Window mainWindow = new Window("Myfirstwidget Application");
		Label label = new Label("This is a Widget");
		Mywidget myTable = new Mywidget("My Non - Collapsable table", createFundsData());
	private static IndexedContainer createFundsData() {
		String[] funds = { "Fund1","Fund2","Fund3" };
		IndexedContainer indexedContainer = new IndexedContainer();
		indexedContainer.addContainerProperty("Funds", String.class, "");
		indexedContainer.addContainerProperty("Size", Integer.class, "");
		for (int nIndex = 0; nIndex < funds.length; nIndex++) {
			Object id = indexedContainer.addItem();
			indexedContainer.getContainerProperty(id, "Funds").setValue(funds[nIndex]
			indexedContainer.getContainerProperty(id, "Size").setValue(
					((Double) (Math.random() * 10000 + 10000)).intValue());
		return indexedContainer;

Mywidget :

public class Mywidget extends Table {
	private static final long serialVersionUID = 1L;
	private Table gridTable;

	public Mywidget(String caption, Container dataSource) {
		gridTable = new Table();
	public void paintContent(PaintTarget target) throws PaintException {
		if(gridTable!=null) {
	public void changeVariables(Object source, Map<String, Object> variables) {}

VMywidget :

public class VMywidget extends Widget implements Paintable
	public static final String CLASSNAME = "v-mywidget";
	protected String paintableId;
	protected ApplicationConnection client;
	public VMywidget() {

	public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
		if (client.updateComponent(this, uidl, true)) {
		this.client = client;
		paintableId = uidl.getId();
		String myTable = uidl.getStringAttribute("table");

well, there is no compilation errors but i get this output:

This is a Widget

The table is not displayed, instead PID is displayed. Can you tell me where I’m going wrong?
Thanks in advanced.

Here you assume Table.toString() produces HTML that could be rendered directly on the client, but Vaadin components do not work like that. I’d recommend reading the general architecture chapters, as well as the chapters about widget creation in the Book of Vaadin.

(Also Mywidget extends Table but also has an internal Table “gridTable” that it also outputs, which seems weird to me…)

Since I’m not familiar with what you’re trying to achieve, this might not be appropriate, but you might want to consider making your component completely server-side without the need to make a client-side widget; for instance a CustomComponent with a layout or the Table directly as composition root.

If you do need to customize the client-side, you might want to extend VScrollTable there, or perhaps take a look at how some widget that contains other widgets is made (VCustomComponent?).

Best Regards,

Thank you. I’ll try your approach.

can you provide me the code to initialize the table widget?

the book
for an example of a static table. Then just add this table component to your layout. There is no need for any client side code etc.

A Table always has a container, by default (currently) a simple IndexedContainer that is created with the table. You can either add items to that container via the Table.addItem() or Table.getContainerDataSource().addItem(), or use your own container instance and call setContainerDataSource().

EDIT: If disallowing column collapsing was the reason why you wanted to create your own table widget, take a look at setColumnCollapsingAllowed() instead.

Thanks.I’ve already created few Application and they are working fine.
But my requirement is to create a custom “widget” say MyGrid and then extend it to VMyGrid.

Well I’m now able to create a custom Widget using
My mistake was that I was assuming that com.vaadin.ui.Table is inherited from

My basic requirement is to create a table with collapsable rows and columns. Can you suggest a good approach? GWT’s Grid does not provide any handy tools to do that.

Thanks in advance.

You can try to use
gwt mozaic

It has more advanced table than gwt (see

be carefull, it is not enouth stable (v 0.4), but anyway it is best free pure gwt component suit