문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top