# Fire Component Event

**URL:** <https://forum.inductiveautomation.com/t/fire-component-event/80937>\
**Category:** Module Development\
**Tags:** perspective\
**Created:** [October 25, 2023, 3:55am UTC](https://forum.inductiveautomation.com/t/fire-component-event/80937 "2023-10-25T03:55:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill.liu](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@bill.liu](https://forum.inductiveautomation.com/u/bill.liu)\
**Post date:** [October 25, 2023, 3:55am UTC](https://forum.inductiveautomation.com/t/fire-component-event/80937/1 "2023-10-25T03:55:10Z")

</div>

How to trigger the "onMessageEvent" from the example Messenger component?

I have tried `this.component.fireEvent("model", "onMessageEvent", event);` in MessageComponentModelDelegate.java but it doesn't work.

[link to code](https://github.com/inductiveautomation/ignition-sdk-examples/blob/da3c7e073686f62dbbd6d228ed55468b6d7f1575/perspective-component/common/src/main/java/org/fakester/common/component/display/Messenger.java#L44)

I figured it out:  
`this.component.fireEvent(EventConfig.COMPONENT_EVENTS, "onMessageEvent", event);`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 25, 2023, 11:53am UTC](https://forum.inductiveautomation.com/t/fire-component-event/80937/2 "2023-10-25T11:53:24Z")

</div>

You generally should not do this. Instead, move the code in the event to a function in a project library script. Then the event becomes a one-liner that calls the real code, and the real code can also be called wherever else you need it.

---

<div class="post-metadata">

**Author:** ![bill.liu](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@bill.liu](https://forum.inductiveautomation.com/u/bill.liu)\
**Post date:** [October 26, 2023, 12:42am UTC](https://forum.inductiveautomation.com/t/fire-component-event/80937/3 "2023-10-26T00:42:05Z")

</div>

Thanks for the reply. I am adding a Component Event on my Perspective Component so the Designer user has the choice of either using the Component Event or adding a Change Script of a perspective property depends on their preference.

The example in `MessageComponentModelDelegate.java` gets me most of the way there. I just needed to figure out the call signature of `com.inductiveautomation.perspective.gateway.api.Component.fireEvent` which is undocumented.
