ValueChangeListener not called on Table

Hi,

I have a customerTable class which extends Table. I set

customerTable.setImmediate(true) 

and added this

  [code]

customerTable.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
System.out.println(“valueChange called”);
Object id = customerTable.getValue();
ebutton.setEnabled(id != null);
}
});
[/code]

But when I select a line from the table this handler is never called. Any idea what might be wrong?
I tried with 6.4.3, 6.3.4 and 6.4.8 w/o any luck.

If I added ItemClickListener it is working fine, but ValueChangeListener not :frowning:

Is it possible that the reason for this behaviour is that I implemented myself Container, Item and Property classes. Do I need to implement in these classes something specific for events? I only implemented the methods for data retrieval

Please suggest what might be wrong, because I can’t find any reasonable explanation.
Thanks in advace

For me, with standard containers, this seems to work, at least for the multi-select case, and I believe a lot of applications and tests would be broken if this were a general problem. Check the equals() method of your item ids to make sure the items are considered distinct from each other.

The PropertyDataSource of the table (keeping track of the selection) should notify the table of changes, but the ContainerDataSource and its items and properties might not need to do so if the data is static. If you don’t set the property data source explicitly, the default implementation should be ok.

Hi,

Did you
setSelectable()
?

customerTable.setSelectable(true);

…it’s easy to forget.

Best Regards,
Marc

The problem is definetely in somewhere in my Container/Item/Property implementations, because when I replace the the container with BeanItemContainer the selections are working correct.

The Item ids are Integers, I implemented it similar to LazyContainer example in contrib, so I suppse there is no need to override equals methods


 public java.util.Collection<?> getItemIds() {
        ArrayList<Integer> ids=new ArrayList<Integer>(size());
        for(int i=0;i<size();i++) {
            ids.add(i);
        }
        return ids;
    }

My container implements only Indexed and Sortable interfaces. There is no code related to any even. Should the containers implement any even related interfaces in order to get notified during row selection from a table?

Please suggest something? Or at least could you point me to the related lines of code from table class which are supposed to notify the container or called the valueChange event

OK, I found what I was doing wrong: containsId method of my cotnainer was always returning false. That was all.

Thanks for your help guys