Xpages SSJS 如何显示数组? [英] Xpages SSJS How to display an array?

查看:19
本文介绍了Xpages SSJS 如何显示数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习 Xpages 编程.我们目前使用的是 domino 8.5.2.我对显示/输入控件越来越熟悉,并且在使用它们显示来自后端多米诺骨牌文档、视图、非数组的范围变量的信息方面取得了一些成功.我还没有发现如何显示动态创建的作用域变量数组的元素.
例如:我创建了一个包含多个元素的数组.我可以使用以下代码将元素打印到 domino 日志:

I have been learning Xpages programming. We are currently using domino 8.5.2. I am gaining familiarity with the display/input controls and I have had some success using them to display information from backend domino documents, views, scoped variables that are not an array. What I have not been able to discover is how to display the elements of a scoped variable array that is created dynamically.
For instance: I create an array with a number of elements. I can print the elements to the domino log with the following code:

for (var i=0; i<array.length; i++) {
    print(array[i])
}

我用什么来显示网页上的各个元素?如果答案很明显,我深表歉意.我确实找到了一篇关于显示二维数组的帖子 - 但无法解释答案.
感谢您的任何指导.---丽莎&

What do I use to display the individual elements on webpage? I apologize if the answer if obvious. I did find one posting about displaying a 2 dimensional array - but was unable to interpret the answer.
Thanks for any guidance. ---Lisa&

推荐答案

使用重复控件并在计算字段中显示重复内的元素:

Use a repeat control and show elements within repeat in a computed field:

<xp:this.beforePageLoad><![CDATA[#{javascript:
    var myTest = []; 
    for (var i=0; i<9; i++) {
        myTest[i] = i; 
    } 
    viewScope.myTest = myTest;
}]]></xp:this.beforePageLoad>
<xp:repeat
    id="repeat1"
    rows="30"
    var="row"
    value="#{viewScope.myTest}">
    <xp:text
        escape="true"
        id="computedField1"
        value="#{javascript:row.toString()}">
    </xp:text>
    <br />
</xp:repeat>

在本例中,数组位于 viewScope.myTest 中.

The array is in viewScope.myTest in this example.

这篇关于Xpages SSJS 如何显示数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆