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 ...