问题描述
以下是我的代码
<rich:select id="cycle_group" value="#{menuCycleBean.menuCycleDetailTO.menuCycleGroupId}" defaultLabel="#{msg['gobal.select.default.label']}"
converter="javax.faces.convert.IntegerConverter">
<f:selectItems value="#{menuCycleBean.cycleGroupList}" var="n" itemLabel="#{n.label}" itemValue="#{n.id}" />
</rich:select>
"menuCycleGroupId"为整数"值,"n.id"为字符串"值.我需要将String转换为Integer.我正在使用以下属性converter="javax.faces.convert.IntegerConverter"
,但出现错误.
"menuCycleGroupId" is "Integer" Value and "n.id" is "String" value. I need to convert String to Integer. I am using following attribute converter="javax.faces.convert.IntegerConverter"
, but it is giving error.
如何将转换器与<rich:select>
一起使用?
How can I use converter with <rich:select>
?
推荐答案
converter
属性必须指向像#{bean.converter}
这样的具体实例,或者包含带有转换器ID而不是标准转换器类名的字符串文字.如果您在标准转换器的 javadoc ,那么您将发现它是IntegerConverter
的javax.faces.Integer
.
The converter
attribute must point to either a concrete instance like #{bean.converter}
or contain a string literal with the converter ID and not the fully qualified converter class name. If you click through CONVERTER_ID
field constant in the standard converter's javadoc, then you'll find out that it's javax.faces.Integer
for the IntegerConverter
.
所以,这应该做:
<rich:select ... converter="javax.faces.Integer" />
这篇关于表达式错误:命名对象:找不到javax.faces.convert.IntegerConverter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!