Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Getting values in Table

Basma Hassabo
1 decade ago Apr 07, 2010 8:46am
Henri Muurimaa
1 decade ago Apr 07, 2010 9:40am

Basma Medhat Hassabo: Hey everyone,
I have a question, I have created a table with 2 columns one is a string and the other is a check box, now i want to get which check boxes are checked, what is the name of the method that will get me the value of the check box within a specific row??

You did not say if the column contains a Boolean or a Checkbox (both can be used), but use Table.getContainerProperty(...) to get the Property (cell) of a certain Item (row). After that you use Property.getValue() to get the current value of the cell.

The Table component is a Select and is always backed by a Container. The Container contains Items (think rows) which in turn have Properties (think columns). The value of a Property of a Item is the value in a cell. You can find out more about Containers in the book.

Here is a quick snippet:

// Define the columns in the table
table.addContainerProperty("String", String.class, "Some string");
table.addContainerProperty("Boolean", Boolean.class, false);


// Add some items (rows) into the table
for (int i = 0; i < 10; i++) {
	table.addItem("" + i);

		new Button("Hit server", new ClickListener() {
			public void buttonClick(ClickEvent event) {
				String message = "<br>\n";
				for (Object id : table.getItemIds()) {

					// Get the Property representing a cell
					Property property = table.getContainerProperty(id,
					// Get the value of the Property 
					Object value = property.getValue();
					if (((Boolean) value) == true) {
						message += id.toString() + " ";

				getMainWindow().showNotification("Checked rows",