Select - getSource

Hi all,

My issue is simple. I have two selects and one listener. How can I know which listener fired the event?


...
  Select select1 = new Select();
  select1.addListener(this);        

  Select select2 = new Select();
  select2.addListener(this);        

...

public void valueChange(Property.ValueChangeEvent event) {
 //event.getSource doesn't exist!  How to know if the event is fired from select1 or select2???
}

Kind regards,
Stijn.

There are tow ways: using one listener, you can find out the firing component by doing ((Component)event.getProperty()).equals(select1) inside the listener method.

Or, alternatively, you can add inline listeners for the Selects like this: select1.addListener(new ValueChangeListener(){ public void valueChange(Property.ValueChangeEvent event) { //specific code here } });