JSF 2.0:< f:viewParam>和默认转换器 [英] JSF 2.0: <f:viewParam> and default converters
问题描述
我想使用标准JSF转换器( javax.faces.convert.DateTimeConverter
)作为视图参数
I would like to use a standard JSF converter (javax.faces.convert.DateTimeConverter
) for a view parameter
来自文档:
您可以使用
组件标记的转换器按类或ID来引用转换器属性。 ID在
应用程序配置资源文件中定义
You can refer to the converter by class or by its ID using the component tag's converter attribute. The ID is defined in the application configuration resource file
然后我尝试了:
<f:viewParam
name = "rangeStartCreationDate"
value = "#{doiListController.model.rangeStartCreationDate}"
converter = "javax.faces.convert.DateTimeConverter"
/>
但我得到了
javax.faces.FacesException: Expression Error: Named Object: javax.faces.convert.DateTimeConverter not found.
然后我尝试了第二个选项(按ID)。我在 faces-config.xml中定义了转换器
I then tried the second option (by ID). I defined the converter in faces-config.xml
<converter>
<converter-id>DateTimeConverter</converter-id>
<converter-class>javax.faces.convert.DateTimeConverter</converter-class>
</converter>
并使用ID
<f:viewParam
name = "rangeStartCreationDate"
value = "#{doiListController.model.rangeStartCreationDate}"
converterId = "DateTimeConverter"
/>
在这种情况下,我得到
Conversion Error setting value 'Tue Jul 24 00:00:00 CEST 2012' for 'null Converter'.
有没有办法让JSF实例化转换器或我必须手动实例化它(在某些情况下) bean)?
Is there a way to let JSF instantiate the converter or to I have to instantiate it manually (in some bean)?
推荐答案
转换器ID是 javax.faces.DateTime
,请尝试
The converter id is javax.faces.DateTime
, so try
<f:viewParam
converter="javax.faces.DateTime"
... />
这篇关于JSF 2.0:< f:viewParam>和默认转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!