覆盖JSF中的默认转换器 [英] Override default converter in JSF

查看:68
本文介绍了覆盖JSF中的默认转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用自定义转换器覆盖JSF的默认转换器.例如,如果我在faces-config.xml中用CONVERTER_ID="javax.faces.Enum"注册一个自定义转换器,将会发生什么. JSF会选择自定义转换器还是仍将使用内置的EnumConverter?

Is it possible to override the default converter of JSF with a custom converter. For instance what will happen if I register a custom converter with CONVERTER_ID="javax.faces.Enum" in faces-config.xml. Would JSF pick custom converter or would it still use the in-built EnumConverter?

考沙尔

推荐答案

您可以定义自定义转换器,并将其用于要覆盖默认转换器的JSF组件:

You can define your custom converter and use it in JSF components that you would like to override the default one: http://www.mkyong.com/jsf2/custom-converter-in-jsf-2-0/

如果您要绝对使用新的而不是已定义的.您可以使用与您希望覆盖的名称相同的名称和程序包来定义新的名称,以便服务器将加载您的类,而不是在JSF jar中定义的那个

If you want to definitely use your new one instead of a defined one. You can define the new one with the same name and package of the one you wish to override, so your server will load your class instead of the one defined in JSF jars

这篇关于覆盖JSF中的默认转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆