Button.doClick() analogue in Vaadin

Dear Vaadin users,

I really miss the functionality which in Swing terms is
javax.swing.AbstractButton#doClick()
, which actually emulates the click on the button, e.g. notifies all listeners. Of course I can store the listeners somewhere separately in my code…

Does it make sense to have such helper function? Perhaps making
com.vaadin.ui.Button#fireClick()
public is quickfix for that.

Here is a dirty one liner to get the job done without extending the button:

 button.changeVariables(button, Collections.singletonMap("state", (Object)true));

If you want a cleaner solution, then extending the Button and opening up the fireClick() would probably be it.

One thing to remember though is that if you are calling this from a server side thread you will need to push the changes to the client side as well.

Yes - we really should have Button.doClick() as outlined here:
http://dev.vaadin.com/ticket/4530

Does the solution John gave work? If I remember correctly, this might throw NPE… See
http://vaadin.com/forum/-/message_boards/view_message/512218
for another example.