ND9中带有组合框的xpages数字转换器 [英] xpages number converter with combobox in ND9
问题描述
在Domino 9服务器上xpages的组合框中,无法将数字转换与numberConvert一起使用.这曾经在8.5服务器上工作.
I'm having trouble using number conversion with numberConvert in a combo box in xpages on a Domino 9 server. This used to work on the 8.5 server.
提交值时,我得到:验证错误:值无效
When I submit the values I get: Validation Error: Value is not valid
我还尝试使用"new javax.faces.model.SelectItem"填充值,但这没有任何区别.
I also tried to populate the values with "new javax.faces.model.SelectItem" but that didn't make any difference.
有人知道如何在ND9的组合框中使用数字吗?
Does anyone know how to use numbers in combo boxes in ND9?
以下是来源(在此示例中,我删除了所有不必要的内容):
Here is the source (I removed everything unneccesary for this example):
<xp:comboBox id="combo" value="#{viewScope.testfield}">
<xp:this.converter>
<xp:convertNumber type="number"></xp:convertNumber>
</xp:this.converter>
<xp:selectItem itemLabel="9" id="selectItem1" itemValue="9">
</xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var arr=new Array("0","1","2"); return arr;}]]></xp:this.value>
</xp:selectItems>
</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>
推荐答案
如果要在ComboBox中选择数字,则必须将comboBox的可能值定义为数字数组,而不是字符串.
If you want to select numbers in a ComboBox you have to define comboBox's possible values as an array of numbers, not strings.
<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>
如果值是作用域变量,则此示例可以完美地无需使用转换器.
This example works perfect without using a converter if the value is a scope variable.
如果条目数量灵活,可以同时使用Adibabu Kancharla的答案中所示的两种方式.
If you have a flexible number of entries you can use both ways shown in Adibabu Kancharla's answer.
数字转换器对于绑定到文档的数字字段是必需的.以下示例适用于 ND853 和 ND9.我必须添加 integerOnly ="true"
:
The number converter is necessary for binding to a document's number field. The following example works for me in ND853 and ND9. I had to add integerOnly="true"
though:
<?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>
这篇关于ND9中带有组合框的xpages数字转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!