单选按钮-将选定的值另存为数字

沙特兹

我有一个带有两个不同选择的单选按钮控件:“ Ja”和“ Nein”。在后台将值1和0保存为数字。但这是行不通的,因为一旦我选择一个值并保存文档(例如,我选择了“ Ja” | 1),该值就会转换为布尔值,并且将保存true而不是1。

<xp:radioGroup id="rbgIsEmployed" value="#{docApplication.IsEmployed}">
   <xp:selectItem itemLabel="Ja" itemValue="1"></xp:selectItem>
   <xp:selectItem itemLabel="Nein" itemValue="0"></xp:selectItem>
</xp:radioGroup>

要保存数字值而不是布尔值,我该怎么做?

纳特·赫尔曼(Knut Herrmann)

使用数字转换器并将itemValues设置为数字:

<xp:radioGroup id="rbgIsEmployed" value="#{docApplication.IsEmployed}">
    <xp:selectItem
        itemLabel="Ja"
        itemValue="${javascript:1}"></xp:selectItem>
    <xp:selectItem
        itemLabel="Nein"
        itemValue="${javascript:0}"></xp:selectItem>
    <xp:this.converter>
        <xp:convertNumber
            type="number"
            integerOnly="true"></xp:convertNumber>
    </xp:this.converter>
</xp:radioGroup>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章