Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ND9中带有组合框的xpages数字转换器_Xpages_Lotus Domino - Fatal编程技术网

ND9中带有组合框的xpages数字转换器

ND9中带有组合框的xpages数字转换器,xpages,lotus-domino,Xpages,Lotus Domino,在Domino9服务器上的xpages中,在组合框中使用numberConvert进行数字转换时遇到问题。这在8.5服务器上使用 当我提交我得到的值时:验证错误:值无效 我还尝试用“newjavax.faces.model.SelectItem”填充这些值,但没有任何区别 有人知道如何在ND9的组合框中使用数字吗 以下是源代码(我删除了本例中所有不必要的内容): 请确保基础表单上的字段“testField”为“Number”类型。 我在8.5.3服务器上也遇到了同样的问题。因此,我编写了

在Domino9服务器上的xpages中,在组合框中使用numberConvert进行数字转换时遇到问题。这在8.5服务器上使用

当我提交我得到的值时:验证错误:值无效

我还尝试用“newjavax.faces.model.SelectItem”填充这些值,但没有任何区别

有人知道如何在ND9的组合框中使用数字吗

以下是源代码(我删除了本例中所有不必要的内容):



请确保基础表单上的字段“testField”为“Number”类型。 我在8.5.3服务器上也遇到了同样的问题。因此,我编写了下面的代码来解决这个问题

    <xp:selectItems>
     <xp:this.value><![CDATA[#{javascript:
var arr = ['0','1','2']
var comboOptions = [];
for (i = 0; i < arr.length; i++){   
    comboOptions.push(new javax.faces.model.SelectItem(parseFloat(arr[i]), arr[i]))
}
return comboOptions}]]>
 </xp:this.value>
</xp:selectItems>

如果您知道如何使用托管bean,则可以简化上述代码。 下面是bean的代码

public class ApplicationSettings implements Serializable{
 private static final long serialVersionUID = 1L;
 private List comboOptions;

 public ApplicationSettings(){
  loadDefaults();
 }

 public void loadDefaults(){
  for(int x = 0; x <= 3; x = x+1){
   SelectItem item = new SelectItem(new Double(x),""+x);
   comboOptions.add(item);
  }
 }

 public List getComboOptions() {
  return comboOptions;
 }
 public void setComboOptions(List comboOptions) {
  this.comboOptions = comboOptions;
 }
}
公共类应用程序设置实现可序列化{
私有静态最终长serialVersionUID=1L;
私人列表选项;
公共应用程序设置(){
loadDefaults();
}
公共void loadDefaults(){
对于(int x=0;x编辑:

如果要在组合框中选择数字,必须将组合框的可能值定义为数字数组,而不是字符串

<xp:this.beforePageLoad><![CDATA[#{javascript:viewScope.testfield = 1}]]></xp:this.beforePageLoad>

<xp:comboBox id="combo" value="#{testfield}">
    <xp:selectItem itemLabel="0" itemValue="${javascript:0}"></xp:selectItem>
    <xp:selectItem itemLabel="1" itemValue="${javascript:1}"></xp:selectItem>
    <xp:selectItem itemLabel="2" itemValue="${javascript:2}"></xp:selectItem>
</xp:comboBox>


如果您使用数字转换器,并且字段类型为数字,则此解决方案适用于8.5.3。但是,当我将相同的代码和表单复制到9服务器时,会出现验证错误:值无效。您是对的。在不使用转换器的情况下,此解决方案可以正常工作。当我将值绑定到数字字段时,问题似乎会出现。我无法使其正常工作,带或不带转换器。在8.5.3上,它工作正常,xpage可以生成带有数值的文档。我想知道我们如何得到不同的结果?你是对的,这个示例对范围变量有效,但对数字字段无效。我也添加了一个数字字段绑定的示例。太好了!现在我让代码正常工作了。8.5.3和9.0之间的差异似乎没有o当字段绑定到数字字段时,只需在9.0上选择整数。非常感谢您的帮助,克努特!
<xp:selectItems value="#{ApplicationSettings.comboOptions}"></xp:selectItems>
<xp:this.beforePageLoad><![CDATA[#{javascript:viewScope.testfield = 1}]]></xp:this.beforePageLoad>

<xp:comboBox id="combo" value="#{testfield}">
    <xp:selectItem itemLabel="0" itemValue="${javascript:0}"></xp:selectItem>
    <xp:selectItem itemLabel="1" itemValue="${javascript:1}"></xp:selectItem>
    <xp:selectItem itemLabel="2" itemValue="${javascript:2}"></xp:selectItem>
</xp:comboBox>
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.data>
        <xp:dominoDocument var="document1" formName="NumberTest"
            action="editDocument"
            documentId="477FF8697EE50EDBC1257B710073DDE3">
        </xp:dominoDocument>
    </xp:this.data>
    <xp:comboBox id="combo" value="#{document1.Number}">
        <xp:selectItem itemLabel="0" itemValue="${javascript:0}"></xp:selectItem>
        <xp:selectItem itemLabel="1" itemValue="${javascript:1}"></xp:selectItem>
        <xp:selectItem itemLabel="2" itemValue="${javascript:2}"></xp:selectItem>
        <xp:this.converter>
            <xp:convertNumber type="number" integerOnly="true"></xp:convertNumber>
        </xp:this.converter>
    </xp:comboBox>
    <xp:message id="message1" for="combo"></xp:message>

    <xp:button value="Label" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete">
            <xp:this.action>
                <xp:save></xp:save>
            </xp:this.action>
        </xp:eventHandler>
    </xp:button>
</xp:view>