I need to build repeat control or (view or data table) that uses scoped variable as data source. And the scoped variable should be an array.. Or even just javaScript array..
scoped variable:
viewScope.MY_TEST = new Array();
viewScope.MY_TEST.push("Test1");
viewScope.MY_TEST.push("Test2");
or array:
var my_arr = new Array();
my_arr.push("Test1");
my_arr.push("Test2");
or even an object/two dimensional array:
viewScope.MY_TEST = [];
viewScope.MY_TEST .push([value1, value2]);
so repeat control should contain e.g. two computed fields one is bind to value1, another to value2...
Or give me an example of just one dimensional array..
Thank you
It's worth looking at java.util.ArrayList or java.util.HashMap. The first gives a one dimensional object, the second a two-dimensional. You'll probably get better typeahead support. HashMap may seem scary, but it's actually very familiar to you - scoped variables are HashMaps.
myMap.keySet()
is what to use as the "value" for your repeat, then assumingvar="key"
you can usemyMap.get(key)
to get the value.If you want to use JavaScript objects, look at the video I did for TLCC's webinar last year of my 2013 IBM Connect session with Mike McGarel "It's Not Herculean...". I do exactly that.
I understand your question the way that you want to use a two dimensional viewScope variable in your repeat control.
You can define such a two dimensional array in JavaScript this way:
or similar to your third code snippet:
The repeat control iterates through the first array level and writes the second level into a variable
row
:You can access the values with
row[0]
androw[1]
.This example renders the following output: