combobox - displaying multivalue numeric field

和自甴很熟 提交于 2019-12-13 02:35:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!