Quantcast
Channel: SCN : All Content - SAP BusinessObjects Design Studio
Viewing all articles
Browse latest Browse all 4216

SDK: How to Extend ZTL Grammar with own Return Types

$
0
0

Purpose

you are writing SDK component and want to allow eg. own objects as return types.


Example

you want to return an array from a script function:

 

SomeArray getAsKeyLabelValueArray ();

 

First Step

Define the Array-Element in your ZTL like this:

 

class org.kalisz.karol.scn.pack.KeyLabelValue {  String key;  String label;  float value;
}

 

Second Step

Define the Array in your ZTL like this:

 

class org.kalisz.karol.scn.pack.KeyLabelValueArray extends Array {  org.kalisz.karol.scn.pack.KeyLabelValueArray (org.kalisz.karol.scn.pack.KeyLabelValue b);
}

 

Third Step

now, you can create your method and retrurn this array.

 

org.kalisz.karol.scn.pack.KeyLabelValueArray getAsKeyLabelValueArrayTest () {*    var a = [];    var itemDef1 = {        "key": "A",        "label": "Text A",        "value": 20    };      a.push(itemDef1);   var itemDef2 = {        "key": "B",        "label": "Text B",        "value": 20    };      a.push(itemDef2);    return a;
*}

Result in BIAL

  • you will be able to loop on this object

 

var keysAndlabelsAsArray = OBJECT_COMPONENT.getAsKeyLabelValueArrayTest();
keysAndlabelsAsArray.forEach(function(element, index) {  LISTBOX_1.addItem(element.key, element.label + "( " + element.value + " )");
});

Live Example soon ...


Viewing all articles
Browse latest Browse all 4216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>