Looping through an array in JellyScript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2015 11:44 PM
Hi all,
I have a single dimension array that was populated in the <g2> tag in UI Page. In the same page, I wanted to loop through this array in the jelly tag to populate a table in HTML. Does anyone knows how to do this? The code I had in <g2> tag is as followed and needs to be converted to jellyscript for the looping:
for (var i = 0; i < assignedIdList.length; i++) {
gs.print(assignedIdList[i]);
}
Your help is appreciated.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2015 12:17 AM
Alex,
You can check this link : Jelly: Over and Over Again...
Also, the code will be something like:
//impArr1 is the Array name
<j:forEach var="jvar_pair" items="$[impArr1]" indexVar="jvar_i">
<g:evaluate var="jvar_cat" expression="var sp = $[jvar_index]; sp;" />
$[javr_cat]
</j:forEach>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2015 12:50 AM
Hi Alex
use this
<j2:forEach var="jvar_upd" items="$[jvar_updates]">
<br/>$[jvar_upd]
</j2:forEach>
jvar_updates is the array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2015 12:52 AM
Hi Alex
use this
<j2:forEach var="jvar_upd" items="$[jvar_updates]">
<br/>$[jvar_upd]
</j2:forEach>
jvar_updates is the array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2015 06:38 PM
Hi everyone,
Thanks for all the replies. I used something similar of the abov
e but I do not seems to get the value through. Below is the part of my code in UI Page.
<g:evaluate>
var colors = [
{ name: 'red', value: '#FF0000' },
{ name: 'blue', value: '#0000FF' }
];
</g:evaluate>
<j:forEach items="${colors}" var="jvar_color">
<tr>
<td>${colors}</td>
<td>${colors.name}</td>
<td>${colors.value}</td>
</tr>
</j:forEach>
It does manage to loop through 2 rows of records but {colors.name} and ${colors.value} returns me an empty value while ${colors} actually returns me the value of org.mozilla.javascript.NativeArray@8b7f18.
Anyone can shed some light to me of what I am doing wrong?
Thank you.