组合框-显示多值数字字段 [英] combobox - displaying multivalue numeric field

查看:63
本文介绍了组合框-显示多值数字字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多值启用数字字段的表单。当它具有多个值时,我想在组合框中的xpage上显示它。但是,我收到了错误500消息。

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.

当我尝试使用多值文本字段实现同一目的时,xpage就会被渲染。

When I try to achieve the same thing with a multi-value text field the xpage got rendered.

我在做什么错了?

<?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>


推荐答案

< xp:selectItems> ; 仅接受字符串值。

将selectItems值代码中的价格数字转换为字符串,然后在

组合框中添加数字或货币转换器。

Convert your price's numbers in selectItems' value code into strings and
add a number or currency converter to your combobox.

作为替代方案,您可以创建带有String标签和数字值的选择项:

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>

这篇关于组合框-显示多值数字字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆