How to use fireComponentEvent()?

Hello,

In the IT Mill Toolkit Reference Manual, it mentions that:
“Events are usually emitted by the framework, but applications may need to emit them too in some situations, such as when updating some part of the UI is required.”

It then goes on to say:
“Some components have a default event type, for example, a Button has a nested Button.ClickEvent class and a corresponding Button.ClickListener interface. These events can be triggered with fireComponentEvent().”

I have a refresh button in my application that updates a table. If possible, I would like to manually trigger a “Button.ClickEvent” for this refresh button when my application first loads or when other actions have taken place, i.e. an item was selected and the delete button was clicked. If I am understanding the documentation correctly, I can do this using fireComponentEvent()? I’ve looked through but found no information regarding this, could somebody please explain how to do this or give a simple example.

Thank you for your help,
Ajay

Hi Ajay,

If I understand correctly what you are doing you probably do not need to use fireComponentEvent(). I would suggest you add a ClickListener to your refresh button which only calls a refresh() method. You can then call the same refresh() method from other places like the ClickListener for your delete button etc. This should accomplish the same thing as firing events manually but results in cleaner code.