Getting values in Table

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??

Thanks

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);

table.setEditable(true); 

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

getMainWindow().addComponent(
		new Button("Hit server", new ClickListener() {
			@Override
			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,
							"Boolean");
					
					// Get the value of the Property 
					Object value = property.getValue();
					
					if (((Boolean) value) == true) {
						message += id.toString() + " ";
					}
				}

				getMainWindow().showNotification("Checked rows",
						message);
			}
		}));
	}