Show dynamically generated lists with a variable number of elements on a list widget in a page

Dear friends,

I generated a array/list within a DSL script that has a variable number of elements. I now would like to show this in a list widget on a page.

Blockquote

var itemArray = newArrayList()
itemArray.add(itemName)

Blockquote

Can the number of elements in the widget be changed from the script ?
Can the objects of the widget (e.g. “title:abc…” be changed from the script ?
Of do I mandatorily need proxy items. (I don’t like the idea of proxy items because my list can be quite long with up to 40 entires).

Thanks a lot for your help.
Guido

Just for your information what I try to do: I want to have a nice call monitor from my Fritzbox via the TR-064 binding. I am using JSONPATH to seperate the JSON string into the 5 arrays. But then I want to modify these arrays with a script. The outcome is ok (I’ve checked this with debug prints) so now my obstacle is to bring the arrays to a nice looking page. Thanks a lot !

my full script:

Blockquote
var String localString = CallListLocalNumbers.state.toString
var String remoteString = CallListRemoteNumbers.state.toString
var String durationString = CallListDuration.state.toString
var String dateString = CallListDate.state.toString
var String typeString = CallListType.state.toString

val parse= [ String parseString, int stringType |
var tr064Actions = getActions(“tr064”,“tr064:fritzbox:thingFritzboxTR064”)
var String letter = “”
var String itemNumber = “”
var String itemName = “”
var int charIndex = 0
var int firstchar = 0
var int secondchar = 0
var int itemCount = 0
var String delimiterChar1 =“”
var String delimiterChar2 =“CURRENTLY_NOT_ACTIVE
var String delimiterChar3 =“CURRENTLY_NOT_ACTIVE

  var itemArray = newArrayList()
        
  if (stringType == 0 || stringType == 1 || stringType == 3) {
     delimiterChar1 = '"'
  } else {
    delimiterChar1 = '['      
    delimiterChar2 = ','
    delimiterChar3 = ']'      
  }        
  
  var String prefix = "x"
  var String parseStringPrefix = prefix.concat(parseString);
  // the first delimiter char should not be at position 0
        
  //logInfo("DEBUG", "length of String: {} chars" , parseStringPrefix.length)
  //logInfo("DEBUG", "total string to be parsed: {}" , parseStringPrefix)

  while(charIndex < parseStringPrefix.length){
    letter = parseStringPrefix.substring(charIndex, charIndex + 1)
    // logInfo("DEBUG", "single letter: {}" , letter)
    if (letter == delimiterChar1 || letter == delimiterChar2 || letter == delimiterChar3){
      //logInfo("DEBUG", "delimiter found: {}" , letter)
      if (firstchar == 0){
        firstchar = charIndex
        secondchar = 0
        //logInfo("DEBUG", "firstchar: {}" , firstchar)
      } else {
        secondchar = charIndex
        //logInfo("DEBUG", "secondchar: {}" , secondchar)        
      }
      if ((firstchar !== 0) && (secondchar !== 0)){
        itemCount = itemCount + 1
        itemNumber = parseStringPrefix.substring(firstchar+1, secondchar)
        switch (stringType) {
          case 0:
            itemName = itemNumber
          case 1:
            itemName = tr064Actions.phonebookLookup(itemNumber, 5)
          case 2: {
            itemName = itemNumber
            charIndex = charIndex - 1
            }
          case 3: {
            // 2021-02-11T16:32:00+01
            itemName = itemNumber.substring(8,10)+'.'+itemNumber.substring(5,7)+'.'+itemNumber.substring(2,4)+' '+itemNumber.substring(11,16)
            }
          case 4:{
            itemNumber =itemNumber.replace(' ','')
            switch (itemNumber) {
              case '1': {  
                itemName = "eingehend"
              }
              case '2': {
                itemName = "verpasst"
              }
              case '3': {
                itemName = "ausgehend"
              }
              case '10': {
                itemName = "abgelehnt"
              }
              }
              charIndex = charIndex - 1
            }
        } 
        itemArray.add(itemName)
        //logInfo("DEBUG", "{}. itemNumber: {} itemName: {}" , itemCount, itemNumber, itemName )
        firstchar = 0
        secondchar = 0
      } 
    }  
    charIndex = charIndex+1
  }
  //logInfo("DEBUG", "itemCount: {}" , itemCount)
  return itemArray      

]

var localArray = newArrayList()
var remoteArray = newArrayList()
var durationArray = newArrayList()
var dateArray = newArrayList()
var typeArray = newArrayList()

localArray = parse.apply(localString,0)
remoteArray = parse.apply(remoteString, 1)
durationArray = parse.apply(durationString,2)
dateArray = parse.apply(dateString, 3)
typeArray = parse.apply(typeString, 4)

logInfo(“DEBUG”, “localArray: {}, size: {}” , localArray, localArray.size )
logInfo(“DEBUG”, “remoteArray: {}” , remoteArray )
logInfo(“DEBUG”, “durationArray: {}” , durationArray )
logInfo(“DEBUG”, “dateArray: {}” , dateArray )
logInfo(“DEBUG”, “typeArray: {}” , typeArray )

Blockquote

sorry for the format. I though with “Blockquote” I can quote code but this seems to be wrong.
Please forgive me, its my first post.
Guido

To get anything to the UI, you have to put it in an Item. There are no array type Items.
The closest would be a Group of other Items. UI widgets may display a list of Group members. None of that is really set up for dynamic changes of membership, though.
Related

How about iterate through your array, do postUpdate with persistency activated.
in MainUI I think you can view an item’s history or maybe even better populate e.g. an oh-list-card with oh-repeater

You can always write your array in a string item (using appropriate delimiters) and use this string item as input for an oh-repeater in the widget. I do this in my rollershutter widget: Custom rollershutter widget with preset configuration