国际化JSF验证中错误消息

比如:<f:inputText ... required="true" />如果为空提交,会报“Validation Error: Value is required.”错误。

如果我要国际化怎么做?

1.在资源文件message_zh_CN.properties和message_语言_国家.properties文件

2.配置faces-config.xml

<application>

    <message-bundle>myvalidate.message</message-bundle>

    <locale-config>

      <default-locale>zh_CN</default-locale>    <!--默认资源文件-->

      <supported-locale>en</supported-locale>    <!--支持的资源文件-->

      <supported-locale>en_IE</supported-locale>   <!--支持的资源文件-->

    </locale-config>

</application>

3.在资源文件中建立一个KEY和Value,当然Value需要转成Unicode码。

javax.faces.component.UIInput.REQUIRED=错误信息:必填项

看看是不是成功了?

下面我把默认错误都列出来,只要制作一个就是国际化的错误消息了。

---------------------------------------------------------------------------

标准JSF错误信息KEY与TEXT

javax.faces.validator.NOT_IN_RANGE

Validation Error: Specified attribute is not between the expected values of {0} and {1}.

错误信息:指定属性值不在[{0},{1}]范围内

javax.faces.validator.NOT_IN_RANGE_detail

The value must be between {0} and {1}.

值必须介于[{0},{1}]之间

javax.faces.validator.DoubleRangeValidator.LIMIT

Validation Error: Specified attribute cannot be converted to proper type.

错误信息:指定属性值超过了double类型的极限

javax.faces.validator.DoubleRangeValidator.MAXIMUM

Validation Error: Value is greater than allowable maximum of ‘‘{0}’’.

错误信息:值大于了允许的最大值“{0}”

javax.faces.validator.DoubleRangeValidator.MINIMUM

Validation Error: Value is less than allowable minimum of ‘‘{0}’’.

错误信息:值小于了允许的最小值“{0}”

javax.faces.validator.DoubleRangeValidator.TYPE

Validation Error: Value is not of the correct type.

错误信息:值不是有效的double类型

javax.faces.validator.LengthValidator.LIMIT

Validation Error: Specified attribute cannot be converted to proper type.

错误信息:指定属性值超过了字符极限

javax.faces.validator.LengthValidator.MAXIMUM

Validation Error: Value is greater than allowable maximumof ‘‘{0}’’.

错误信息:值长度大于了允许的最大值“{0}”

javax.faces.validator.LengthValidator.MINIMUM

Validation Error: Value is less than allowable minimumof ‘‘{0}’’.

错误信息:值长度小于了允许的最小值“{0}”

javax.faces.component.UIInput.CONVERSION

Conversion error during model data update

模型数据更新期间转换错误(字面翻译)

javax.faces.component.UIInput.REQUIRED

Validation Error: Value is required.

错误信息:必填项

javax.faces.component.UISelectOne.INVALID

Validation Error: Value is not valid.

错误信息:选择内容无效

javax.faces.component.UISelectMany.INVALID

Validation Error: Value is not valid.

错误信息:选择内容无效

javax.faces.validator.RequiredValidator.FAILED

Validation Error: Value is required.

错误信息:必填项

javax.faces.validator.LongRangeValidator.LIMIT

Validation Error: Specified attribute cannot be converted to proper type.

错误信息:指定属性值超过了long类型的极限

javax.faces.validator.LongRangeValidator.MAXIMUM

Validation Error: Value is greater than allowable maximum of ‘‘{0}’’.

错误信息:值大于了允许的最大值“{0}”

javax.faces.validator.LongRangeValidator.MINIMUM

Validation Error: Value is less than allowable minimum of ‘‘{0}’’.

错误信息:值小于了允许的最小值“{0}”

javax.faces.validator.LongRangeValidator.TYPE

Validation Error: Value is not of the correct type.

错误信息:不是有效的long类型

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值