如何在 inputText 中显示指定值?(XPages)

How can I show a specified value at inputText?(XPages)

我有如下图的表格

如果第一项 Days 有值,它将显示 "Division processing"。

如何编写"Purchase progress"中的代码?

也许像这样?

var doc = purchase.getDocument();
var DAY_A0 = doc.getItemValue("DAY_A0"); //DAY_A0 = 1
if(DAY_A0 == "")
   return false;
else
   return "Division processing";

相反,如果第一项Days为空值,则"Division processing"不会显示出来。

像这样:

正如您在 the documentation getItemValue returns 和 java.util.Vector.

中所读到的

getItemValue(name:string) : java.util.Vector

Return value
java.util.Vector

Description
The value or values contained in the item. The data type of the value depends on the data type of the item.

要检查向量中是否有内容,您需要生成一个迭代器并循环遍历(来自链接帮助的示例):

if (doc.hasItem(itemname)) {
    var itemvalues:java.util.Vector = doc.getItemValue(itemname);
    var iterator = itemvalues.iterator();
    while (iterator.hasNext()) {
        var itemvalue = iterator.next();
        //do your check here...
    }
}

但是有一个更简单的方法:使用 getItemValueString。然后你上面的代码完全按照你想要的方式工作:

var DAY_A0 = doc.getItemValueString("DAY_A0"); //DAY_A0 = 1