获取所选文档的unid并保存到范围变量

时间:2012-08-21 12:26:44

标签: xpages

我带有复选框的viewPanel1。通过单击按钮,我希望将所选项的univ id(逗号分隔)保存到范围变量中。我试过这个:

var viewPanel=getComponent("viewPanel1"); var docIDArray=viewPanel.getSelectedIds(); for(i=0;i < docIDArray.length;i++){ var docId=docIDArray[i]; sessionScope.put("test",+docId); }

3 个答案:

答案 0 :(得分:1)

另外,不要忘记作用域变量可以包含数组,因此您不需要对数组进行打包/取消装箱:

sessionScope.put(“SelectedIds”,getComponent(“viewPanel1”)。getSelectedIds());

答案 1 :(得分:0)

您可以做的是以下

var vPanel = getComponent("viewPanel");
docIdArray = viewPanel.getSelectedIds();
sessionScope.put("SelectedIds",@Implode(docIdArray,","));

答案 2 :(得分:0)

var viewPanel=getComponent("viewPanel1");
var docIDArray=viewPanel.getSelectedIds();
var unidArray = new Array();
for(i=0; i < docIDArray.length; i++) {
   var unid=database.getDocumentByID(docIDArray[i]).getUniversalID();
   unidArray.push(unid);
}
sessionScope.put("test", @Implode(unidArray, ","));

这可能会这样做。