gpt4 book ai didi

java - JSF 2.0 : and default converters

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:21:35 25 4
gpt4 key购买 nike

我想为 View 参数使用标准的 JSF 转换器 (javax.faces.convert.DateTimeConverter)

来自文档:

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

中定义了转换器
<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 中)?

最佳答案

转换器id是javax.faces.DateTime,所以试试

<f:viewParam
converter="javax.faces.DateTime"
... />

关于java - JSF 2.0 : <f:viewParam> and default converters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11628169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com