JSF:针对不同验证器标签的不同验证消息? [英] JSF: Different validation message for different validator tags?

查看:227
本文介绍了JSF:针对不同验证器标签的不同验证消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的JSF + Primefaces应用程序中。我使用JSF验证器标签来验证文本框的输入

In my JSF+Primefaces application. I am using JSF validators tags to validation the input of text box

<p:inputText value="#{createAccessPrivilegeBean.name}" id="name" label="name" size="55" required="true"
    requiredMessage="#{messages.requiredError}" validatorMessage="#{messages.alphaNumericError}">
    <f:validateRegex pattern="#{validatorBean.accessprivilegeValidator}"></f:validateRegex>
    <f:validateLength maximum="10"></f:validateLength>
</p:inputText>

现在对于必需的消息,我在requiredMessage属性中为我正在使用的所有其他验证标签指定了消息我已经在validatorMessage属性中定义了消息。

Now for required message I had specified the message in requiredMessage attribute for all other validation tags I am using common message is coming which I have defined in validatorMessage attribute.

我需要单独的消息进行不同的验证,如果validateRegex失败我需要不同的验证消息或者如果validateLength失败我需要不同的验证消息。

I need separate message for different validation like if validateRegex failed I need different validation message or if validateLength fails I need different validation message.

我该怎么做?

推荐答案

这里是该解决方案的链接:

Here is the link for the solution:

http://www.mkyong.com/jsf2/customize-validation-error-message-in-jsf-2-0/

感谢Daniel。

这篇关于JSF:针对不同验证器标签的不同验证消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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