2017-10-13 65 views
0

我想從使用果凍腳本的對象數組中讀取值,但無法這樣做。在腳本之後,我試圖讀取值但它不工作。如何閱讀使用果凍腳本的對象數組?

<?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"> 
 
\t <style> 
 
\t \t tr.buttons{height:10px;} 
 
\t </style> 
 
<g:ui_form> 
 
    <g:evaluate var="jvar_short_text" expression="RP.getWindowProperties().short_text" /> 
 
    <g:evaluate 
 
\t \t \t var="jvar_bot_param" 
 
\t \t \t object="true" 
 
\t \t \t expression="RP.getWindowProperties().bot_param" /> 
 
    <table width="100%"> 
 
\t \t <j:forEach items="${jvar_bot_param}" var="jvar_param" indexVar="i"> 
 
\t \t \t <p>${jvar_bot_param}</p> 
 
\t \t \t <g:evaluate jelly="true" object="true"> 
 
\t \t \t \t var botparam = jelly.jvar_param[i].label; 
 
\t \t \t \t var botName = jelly.jvar_param[i].name; 
 
\t \t \t </g:evaluate> 
 
\t \t \t <p>${botparam}</p> 
 
\t \t \t <p>${botName}</p> 
 
\t \t </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

試試這個,應該工作:

<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>