cancel
Showing results for 
Search instead for 
Did you mean: 
SAP Community Downtime Scheduled for This Weekend

ZTL Reference?

jonh_goldberg
Active Participant
0 Kudos
384

Hello All,

I am trying to wrap my head around the syntax and capability within a component's ztl file.  I've played around with it a bit and it seems to be a javascript implementation - objects/methods such as JSON.parse(), etc... are there.  It's certainly more fully featured than BIAL.  Should we assume that it is some flavor of ECMAScript?

Is it possible to create shared .js or .java libraries/classes which can be referenced within multiple ztl's?

Is there some object which contains the design studio application components within - I'd very much like to dynamically reference components, something like:

window['APPLICATION']. instead of APPLICATION.

or

datasources['DS_1']. instead of DS_1.?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Karol-K
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Jon,

ZTL is executed in Rhino Engine, which is a bit stripped JS engine - comparable to the JS engines in the browser, but some global statements are not working (eg. window). But basically you can use a lot of JavaScript features there, you can check in detail the links from Mustafa on it, especially the Debug Inspector code which goes deep into this area.

For reuse. You could create a shared library component, and call it from other components (like I have done this in the debug inspector tool, where I call the DEBUG.<method> from other ZTL methods. The problem is only, you have no chance that the library will be placed in the application this way...

So, the other option is to use inheritance of classes in ZTL, like this one which we use in the component model in the sdk community package, see here for the base class for community component, and then we just extend this component from all implementations. Then all implementations are able to access the base component methods (which can be also defined as private since 1.4 SP1).

Hope this explanations help you.

Karol

Answers (1)

Answers (1)

MustafaBensan
Active Contributor
0 Kudos

Hi Jon,

As I understand it the component ZTL is more like a Java language implementation.  However, in addition to this, you can also call any of the BIAL script APIs within a ZTL method as described in the Binding Events to Design Studio Script Methods section of What's Coming in Design Studio 1.4 SDK.

I'm not sure if you can create shared java libraries and suspect that .js libraries referenced in the <jsinclude> tags of the contribution.xml file are probably not accessible from ZTL methods, although I haven't tried this myself. 

To get an idea about how to dynamically reference components you can refer to the source code of Design Studio SDK: Component Manager by Karol Kalisz.

Regards,

Mustafa.

jonh_goldberg
Active Participant
0 Kudos

Thanks for the helpful information; I'd not seen that Component Manager but it looks like just the kind of thing I'm hoping to do.  As I dug in a bit further, seems like ZTL uses java for the function definitions and arguments/return types, but within the functions, the code is javascript.  I did figure out that custom functions can be defined and the objects types exposed in BIAL can be used as arguments to the functions, so you can (for example) pass a reference to a DataSource into a custom function defined in the ZTL.  It feels like there is a lot of power here, and it would be nice if SAP could publish a bit more about what is possible.

From my basic understanding, seems like all code directly interacting with the 'Back-End' - retrieving data, setting state on the application or other components, etc... needs to be defined with the ZTL, while code more related to managing the UI would be implemented in the component.js.  The functionality available within the component.js is fairly standard and I'm feeling quite comfortable with it, however seems like any analytic app of reasonable complexity would require a rich interaction with the application object model.

MustafaBensan
Active Contributor
0 Kudos

Hi Jon,

I think you've made a very good assessment of the ZTL functionality and completely agree with the need for rich interaction with the application object model.  Hopefully we will see SDK feature enhancements in this area with future releases of Design Studio.

You may also find these blogs relevant: 

Design Studio SDK: Examples for Binding Events to ZTL Scripts

Design Studio SDK: BIAL and ZTL Debugger Code Inspector Tool

Scripting Case: How to manage debugging in BIAL and ZTL?

Regards,

Mustafa.