Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Adding/Removing Listeners vs Using a flag to Enable/Disable
My ComboBox needs to have multiple listeners as Focus, Blur, TextChange, ValueChange. And these listeners needs to be enabled and disabled based on specific conditions. For Combo Box I have an issue that when I try to add and remove these listeners then when I click drop down of Combo Box it gets bank and does not show any values in combo box and second when I click it works. I noticed that the culprit seems to be adding/removing focus listener because when I comment the adding/removing of focus listener then this issue goes away. When I changed the focus listener to use a flag and I make that flag true/false to enable/disable focus listener (instead of adding/removing) then also this issue goes away.
Is it ok to use a flag to maintain enable/disable status of listener instead of adding/removing listener? What are pros and cons? Anybody came across this situation before?
thanks
dheeraj