on 12-07-2017 10:35 AM
Hi,
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?
Florian,
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.
Regards,
Mustafa.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Mustafa,
thank you for your quick response.
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.
Regards,
Florian
Hi Mustafa,
yes, I mean script that the user has defined...
Something like this (just an example...):
void doSomething(){*
//Execute some pre-defined script
APPLICATION.loadDataSources([DS_1, DS_2]);
//Execute some user-defined script
try{
var script = this.userScript;
eval(script);
}catch(e){ APPLICATION.createErrorMessage("Error: " + e); }
*}
This would work for certain cases, but I hoped that there is a better solution without using eval().
Regards,
Florian
Hi Florian,
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.
Regards,
Mustafa.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.