Event Object from a Table

I have a table, and I’m trying to send an Event when something is clicked. Right now, I can see the event come through when something is clicked but I can’t seem to get any information out of the event.

I have tried logging these three things:

log.info("EVENT: "+event.getProperty());
            	
            	log.info("EVENTCLASS " + event.getClass().getName());
            	
            	log.info("VALUE: "+event.getProperty().getValue());

But I get

EVENT: 3
EVENTCLASS com.vaadin.ui.Field$ValueChangeEvent
VALUE: 3

How do I get something out of it like perhaps some of the Clicked Row’s content?

Any advice would be a huge help, thanks!

Lets see what you are adding to the table.

See the book of vaadin on how to addItems to a table.

Just for you to know.
An item is like a row in an excel sheet and a property is like each column which maybe of different type (int ,float,string) & a container is like the whole table.

Thanks for your response, I couldn’t seem to find it in the book of Vaadin so I just used a reference array to associate the rows content with event.getProperty().getValue()

Hi,

For future reference: The event.getProperty().getValue() returns the selected item(s) in the Table (or whatever component the listener is attached to). This means that in order to access the values of the columns in the selected row you can do the following:

Object itemId = event.getProperty().getValue();
if (itemId != null) {
    Item selectedItem = myTable.getItem(itemId);
    System.out.println(selectedItem.getItemProperty("column1").getValue());
}

HTH,
/Jonatan

A small correction to the text (the code is correct): The event.getProperty().getValue() returns the
identifier
of the selected item(s) in the Table. If the table is in multi-select mode, a Collection (in practice a Set) is returned.

Thank you!