AbstractComponent.getListeners
takes the event type class as an argument.
Pass it a Property.ValueChangeEvent
or one of it's implementations, a Field.ValueChangeEvent
or Label.ValueChangeEvent
, depending on your use case.
Domanda
The problem is, I cannot find listeners having been added to the table. It seems the method getListeners doesn't work properly. It returns an empty collection. My code:
table.addValueChangeListener(new MyListener());
System.out.println("ListenerCount="+table.getListeners(ValueChangeListener.class).size());
Console output:
ListenerCount=0
What is wrong? I expected it would return 1.
Soluzione
AbstractComponent.getListeners
takes the event type class as an argument.
Pass it a Property.ValueChangeEvent
or one of it's implementations, a Field.ValueChangeEvent
or Label.ValueChangeEvent
, depending on your use case.
Altri suggerimenti
If you read the API very carefully you'll see that you need to provide the event type of your listener:
java.util.Collection<?> getListeners(java.lang.Class<?> eventType)
Returns all listeners that are registered for the given event type or one of its subclasses.
In your case:
table.getListeners(ValueChangeEvent.class);