
Feike Visser wrote...
What I can think of that you use a Java/JS implementation, whereby you pass the numeric value.
Then the Java/JS returns an array/list with the correct size, that you can use with data-sly-list/data-sly-repeat
Hope this helps.
Thanks @Feike for the suggestion it's really helpful :),
I used "Javascript Use API" implementation to achieve this...
In my .js file after getting the dialog integer value, i'm creating an array based on the value.
Following is the code of my "itemCount.js" file :
"use strict"; use(function () { var count = {}, properties = granite.resource.properties; count = properties["loopCountValue"]; if(count == "2"){ count = [1,2]; } if(count == "3"){ count = [1,2,3]; } if(count == "4"){ count = [1,2,3,4]; } if(count == "5"){ count = [1,2,3,4,5]; } return count; });
Now in my .html file, using Sightly List (data-sly-list) i'm rendering data into UI successfully.
Following is the code of my "testCount.html" file :
<sly data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}" /> <sly data-sly-use.itemCount="itemCount.js" data-sly-unwrap /> <sly data-sly-test="${!itemCount}"> <div> <h2>Iterate a sightly loop based on Integer value passed from dialog.</h2> </div> </sly> <sly data-sly-test="${itemCount}"> <p>Test Count ${itemCount}</p> <ul data-sly-list="${itemCount}"> <li>ITEMS : ${item}</li> </ul> </sly>