更改默认消息“验证错误:必须输入值".只是“需要值" [英] Change the default message "Validation Error: Value is required" to just "Value is required"

查看:118
本文介绍了更改默认消息“验证错误:必须输入值".只是“需要值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以修改此默认required="true"验证消息以仅显示必填值"吗?

Can I modify this default required="true" validation message to show only "Value is required"?

formId:inputId:验证错误:值为必需.

formId:inputId: Validation Error: Value is required.

推荐答案

两者都使用输入组件的requiredMessage属性:

Either use the input component's requiredMessage attribute:

<x:inputXxx ... required="true" requiredMessage="Value is required" />

在包含自定义消息模板的类路径中创建一个属性文件:

Or create a properties file in the classpath which contains the custom message template:

javax.faces.component.UIInput.REQUIRED = Value is required.

,并已在faces-config.xml中注册为消息束:

and is been registered as message bundle in faces-config.xml:

<application>
    <message-bundle>com.example.CustomMessages</message-bundle>
</application>

上面的示例假定文件名是CustomMessages.properties,并放在com.example包中.您可以将其命名并放置在任意位置.

The above example assumes that the file name is CustomMessages.properties and is been placed in com.example package. You can name and place it wherever you want.

您可以在 JSF规范.

这篇关于更改默认消息“验证错误:必须输入值".只是“需要值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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