Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在jsf上将inputtext值转换为大十进制_Jsf_Converters - Fatal编程技术网

在jsf上将inputtext值转换为大十进制

在jsf上将inputtext值转换为大十进制,jsf,converters,Jsf,Converters,每当我们使用inputtext作为十进制值时,我们都会执行如下操作: 其中,valorMinimoTransiente是一个字符串,当它转到操作时,我将其转换为BigDecimal 我这样做是因为我们的十进制数有逗号,而不是点,当你试图转换类似的东西时 4,56 对于BigDecimal,它给出了一个异常 那么,有没有一种方法可以在不经过整个过程的情况下获得BigDecimal值 顺便说一句,我正在运行JSF1.2和richfaces 3.3.3。Yekes!听起来您不得不在旧的应用服务器

每当我们使用inputtext作为十进制值时,我们都会执行如下操作:


其中,
valorMinimoTransiente
是一个字符串,当它转到操作时,我将其转换为
BigDecimal

我这样做是因为我们的十进制数有逗号,而不是点,当你试图转换类似的东西时

4,56
对于
BigDecimal
,它给出了一个异常

那么,有没有一种方法可以在不经过整个过程的情况下获得
BigDecimal


顺便说一句,我正在运行JSF1.2和richfaces 3.3.3。

Yekes!听起来您不得不在旧的应用服务器上使用JSF1.2,比如WebSphereApplicationServerV6.1

您可以使用标准的BigDecimalConverter:

<f:converter converterId="javax.faces.BigDecimal" />
要使用自定义转换器,您可以使用:

<h:inputText value="#{someBean.field}" converter="bigDecimalConverter"/>

或:


我已经很长时间没有使用JSF1.2了,但是有可能注释是JSF2.0约定。如果是这样,您必须以老式的方式注册自定义转换器:faces-config.xml:

<converter>
    <description>
        Some description here (optional)
    </description>
    <converter-id>bigDecimalConverter</converter-id>
    <converter-class>
        com.companyname.project.converters.BigDecimalConverter
    </converter-class>
</converter>

此处有一些说明(可选)
大小数转换器
com.companyname.project.converters.BigDecimalConverter
参考资料:

<h:inputText value="#{someBean.field}">
    <f:converter converterId="bigDecimalConverter"/>
</h:inputText>
<converter>
    <description>
        Some description here (optional)
    </description>
    <converter-id>bigDecimalConverter</converter-id>
    <converter-class>
        com.companyname.project.converters.BigDecimalConverter
    </converter-class>
</converter>