Is there any possibility in "Component SDK Development" to fire events in contribution.ztl?

I'm developing a "Component SDK" for the Lumira Designer. We have a component with an event "onLoad", which should execute some custom Design Studio script.

I know, we can fire this event from client javascript using fireEvent("onLoad"). However, I'm just wondering if there is any simple solution to fire this event from server side (in contribution.ztl).

A workaround is to change a component property in a ztl method, which triggers the component setter on the client side, where we can call fireEvent("onLoad"), which finally results in a server roundtrip again...

As we start on the server side and end on the server side, this way (server-client-server) seems to be unnecessary.

So, is there any possibility to fire events in contribution.ztl on server side?

Events are not supposed to be fired from a ZTL function. Although ZTL functions are executed on the server side, they are always called from the client side. Even if it were possible to trigger an event within a ZTL, how were you expecting to trigger the ZTL function from the server side? This is not possible.

I understand your concern about unnecessary server round-trips but this is the way Lumira Designer has been architected so you must develop your SDK component accordingly.

In any case, I would have thought that it makes more sense to trigger an "onLoad" event from the client side because presumably this should occur when the component is initialised or rendered.

Okay, you are right, the "onLoad" event was an example. The main idea was to execute predefined ZTL script in combination with custom Designer script without using the eval() function. Therefore, I thought about triggering an event directly from a ZTL function to avoid server round-trips.

But I can understand that this is the way the Lumira Designer has been architected. I just noticed that even the "event handler methods" of the basic components (like BUTTON_1.onClick();) are marked as depracted now. At least, it is coherent now.

When you say "custom Designer script", do you mean script that the user has defined, or just pre-defined script code that is supplied with your component? If it is the latter, why don't you simply execute that script code within the ZTL?

My understanding is that you want to execute a user-defined script which is actually dependent on a pre-defined ZTL script being executed first. The architecturally correct way of implementing this is to provide a ZTL script API for the pre-defined script. Then in the appropriate event, the user would execute the component-specific API method script first followed by the user-defined script. I do not recommend using the eval() function to execute the user-defined script within a ZTL function.

The example you have provided is too generic for me to provide a more specific recommendation. If you are able describe a real scenario then I could provide further guidance accordingly.