我有一个 View ,其中包含一些文档,其中包含我想要解答的有关采购订单的各种问题。
通过重复,我列出了所有问题。有几种不同类型的问题,因此我仅根据 FieldType 列值呈现我需要的答案字段。我想从问题文档的 DialogChoices 字段中提取组合框的选项。
我目前在空组合框后面的下一行中显示为纯文本的选择,而不是显示为 selectItems。我的代码哪里出错了?
<xp:comboBox id="comboBox1">
<xp:this.rendered><![CDATA[#{javascript:rowData.getColumnValue("FieldType") == "Dialog Box"; }]]></xp:this.rendered>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var doc:NotesDocument = rowData.getDocument();
var choicesVector:java.util.Vector= doc.getItemValue("DialogChoices");
var choices = [];
// loop through the vector, doing push into the array
for (i=0; i<choicesVector.size(); i++) {
choices.push (choicesVector.elementAt(i))
};
return choices;}]]>
</xp:this.value>
</xp:selectItems>
</xp:comboBox>
最佳答案
奇怪,但是使用上面代码的测试数据库似乎没有给我奇怪的结果。也许是因为数据实际上不是一个 vector 而只是一个字符串?
这里有一些提示:
您可以在代码中更改的第一件事是从字段中获取所有数据的循环。由于组合框的 value 属性已经需要一个数组或 vector ,因此您可以将代码更改为:
<xp:this.value><![CDATA[#{javascript:var doc:NotesDocument = rowData.getDocument();
return doc.getItemValue("DialogChoices");
}]]>
</xp:this.value>
但最好完全删除 getDocument 调用。如果可能,您可以在用于重复数据源的 View 中添加一列。在此列中,您可以从现场目录获取数据。这样你就可以使用viewentry的getColumnValue(),这是一种性能优化。像这样的东西:
<xp:selectItems>
<xp:this.value><![CDATA[#{try{
return rowData.getColumnValue("DialogChoices");
}catch(e){// do something }]]>
</xp:this.value>
</xp:selectItems>
关于java - 重复中组合框的选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16111614/