Table problem

Hi!

I want to get the value of an element of a table when I click on it.
I tried mytable.getvalue(); but it didn’t work.

Thanks for your help!

Hi fernanda

you have to addListener to your table like this



mytable.getTable().addListener(new Property.ValueChangeListener() {

			@Override
			public void valueChange(ValueChangeEvent event) {
				//check is item is not empty
                               if (event.getProperty().getValue()!=null){
                                      //then get the item you have click on table
                                      Item item = mytable.getTable().getItem((Integer) event.getProperty().getValue());
                                      //and acces to a property of your item like 
                                      Integer myObjectProperty =  (Integer) item.getItemProperty("propertyname").getValue();                                 
 
                              }

			}
		});

i recommended to make
five minute version tutorial
and then One hour version bu before that read part 9. Binding Components to Data on the book of vaadin good luck

Hi Antonio

Thank you! Im going to try it :slight_smile: