问题
I have a form which contains a multi-value enabled numeric field. I would like to display it on an xpage in a combobox when it has multiple value. However I get the error 500 message.
When I try to achieve the same thing with a multi-value text field the xpage got rendered.
What am i doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="doc" formName="test"
action="editDocument">
</xp:dominoDocument>
</xp:this.data>
<xp:table>
<xp:tr>
<xp:td>
<xp:label value="Label:" id="lb"
for="label1">
</xp:label>
</xp:td>
<xp:td>
<xp:comboBox id="cbLabel" value="#{doc.label}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:return doc.getItemValue("label")}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Price:" id="pr"
for="price1">
</xp:label>
</xp:td>
<xp:td>
<xp:comboBox id="cbPrice" value="#{doc.price}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:return doc.getItemValue("price")}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:td>
</xp:tr>
</xp:table>
</xp:view>
回答1:
<xp:selectItems>
accepts String values only.
Convert your price's numbers in selectItems' value code into strings and
add a number or currency converter to your combobox.
As an alternative, you can create select items with a String label and a number value:
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
var items = new java.util.ArrayList();
for (value in doc.getItemValue("price")) {
var item = new javax.faces.model.SelectItem();
item.setLabel(value.toString());
item.setValue(value);
items.add(item);
}
return items}]]></xp:this.value>
</xp:selectItems>
来源:https://stackoverflow.com/questions/36932102/combobox-displaying-multivalue-numeric-field