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

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

问题描述

我可以修改这个默认的 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.

推荐答案

Either 使用输入组件的 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中注册为消息包:

<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.

您可以在 的第 2.5.2.4 章中找到所有消息键的概述JSF 规范,例如 javax.faces.component.UIInput.REQUIRED_detail,以防您使用它们.

You can find an overview of all message keys in chapter 2.5.2.4 of the JSF specification, such as javax.faces.component.UIInput.REQUIRED_detail in case you're using them.

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

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