how to handle table row selection change via keyboard?

I have a table that responds to row selection in a table using a ItemClickListener, and that works fine. The table is selectable, so after clicking on it the user can use the keyboard to move the selection to another row, but I can’t figure out how to detect that. I’ve tried adding a ValueChangeListener, that seems to get events on mouse clicks but not key presses. Am I missing something?

Based on searching through the forums, it seems like this should work:

        table.addListener(new Property.ValueChangeListener()
            public void valueChange(ValueChangeEvent event)
                logger.debug("~~~~~ " + event.getProperty());

I see the log message when I click on a row, but I don’t see it when I use up/down arrow keys to move to a different row.

Yes, it is the “value” of the table that gets changed when the selected row changes. So a ValueChangeListener is the correct place to detect that (just make sure your Table is in immediate mode to get the value change event without any delay by calling setImmediate(true)).

As I say, I believe ValueChangeListener is supposed to work but doesn’t. I have setSelectable(true) and setImmediate(true), when I use arrow up/down keys the selection color moves, but my ValueChangeListener doesn’t get called. I’m using Vaadin 6.8.2.


The same problem. Keyboard UP/DOWN listeners.

Still no news?

Sorry, I am stupid.


makes the trick.

Thanks, ValueChangeListener works parfaitment for me.

Using vaadin 7; however, facing the same problem. The setImmediate=true is called and the listener is added but nothing is being sent to the handler. Any help?

Hello Imran,

please check this example
You may have an error in your code

Thank you very much for the link. Very strange, I have done exactly the same thing; however, it is still not working. :frowning:
Can it be because of vaadin version or something? Is there a way to search vaadin bug database?

Hello Imran,

it’s unlikely because this is a very basic feature. For example I am using vaadin 7.1.x and ValueChange events working like a charm.

Thank you very much, it is working.The problem was not with the table compoenet or anything else. The problem was with that configuration I did.!/thread/7517823
. As a result of that, all of my items had the same value. So, the value never changes.