Responding to clicking a specific column of a Vaadin table row

I am new to Vaadin. I have three different views. View1 has a table with column1,column2. For a particular table row,when i click on column1,i want to navigate to view2 and when i click on column2 i want to be able to navigate to view3. I can respond to the row click as a whole using the ValueChanged event.But how do i handle click on the specific column of the row? The way i am handling the row-click is as follows

summaryTable.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {

            String provider = summaryTable.getContainerProperty(summaryTable.getValue(), "provider").toString();
            UI.getCurrent().getNavigator().navigateTo(ViewsEnum.PROVIDERS.viewName()+"/"+provider);
        }
    });

Please see http://stackoverflow.com/questions/19120947/responding-to-clicking-a-specific-column-of-a-vaadin-table-row for more details

Hi,

add an ItemClickListener to the Table. From the event you can get itemId (=row) as well as propertyId (=column) where the click occurred.

-tepi

Thanks Teppo.I have a question though.
Earlier i was using the itemclick listener, but to get the row id i was using
summaryTable.getContainerProperty(summaryTable.getValue(), “provider”).getValue().toString(); (doesnt work).
Using the below code works.
summaryTable.getContainerProperty((Integer)event.getItemId(), “provider”).getValue().toString();
I found that summaryTable.getValue() gives the right value for the row in ValueChangeListener but not in ItemClickListener.

Why does this happen? I am sure both events were being raised in my program.

Anusha

An itemClick can occur without the value changing, and any possible value change hasn’t been applied yet at that point (if it ever will). You can consider it a lower level event than a value change.

Thus, like for TextChangeEvent and other “very immediate” events, you need to get the clicked item or the changed text etc. from the event.