我正在尝试使用果冻脚本从对象数组中读取值,但是无法这样做。在脚本之后,我试图读取值,但它不起作用。
<?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.
答案 0 :(得分:0)
试试这个,应该有效:
<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>