How to read array of object using jelly script?

I am trying to read the values from an array of an object using the jelly script but not able to do so.Following the script, I was trying to read the values but it is not working.

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="jelly:core" xmlns:g2="glide">
	<style>
		tr.buttons{height:10px;}
	</style>
<g:ui_form>
  <g:evaluate var="jvar_short_text" expression="RP.getWindowProperties().short_text" />
  <g:evaluate
			  var="jvar_bot_param"
			  object="true"
			  expression="RP.getWindowProperties().bot_param" />
   <table width="100%">
		 <j:forEach items="${jvar_bot_param}" var="jvar_param" indexVar="i">
			 <p>${jvar_bot_param}</p>
			 <g:evaluate jelly="true" object="true">
				 var botparam = jelly.jvar_param[i].label;
				 var botName  = jelly.jvar_param[i].name;
			 </g:evaluate>
			 <p>${botparam}</p>
			 <p>${botName}</p>
		 </j:forEach>
     <tr id="dialog_buttons" class="buttons">
        <td colspan="2" align="right">
           <g:dialog_buttons_ok_cancel ok='return validateComments(${jvar_bot_param})' ok_type="button" cancel_type="button" />
        </td>
     </tr>
  </table>
</g:ui_form>
</j:jelly>

Var jvar_bot_param has the following data:

[{
"name": "incident_sysid",
"label": "Incident sysid",
"type": "text",
"default": "859245f94ffe7e80c5a3c3818110c7fc"
}]

Can someone please look into my code and suggest me how to retrieve the data from array.
728x90

1 Answers How to read array of object using jelly script?

Try this, should work:

<j2:forEach items="$[jvar_bot_param]" indexVar='i'>
    <g2:evaluate>
        var idx = parseInt("$[i]");
        var botparam = jvar_bot_param[idx].label;
        var botName = jvar_bot_param[idx].name;
    </g2:evaluate>
    <p>$[botparam]</p>
    <p>$[botName]</p>
</j2:forEach>

1 year ago