Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF: Different validation message for different validator tags?

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>

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.

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.

how Can I do that ??

like image 927
Dhruv Bansal Avatar asked Jan 25 '26 19:01

Dhruv Bansal


1 Answers

Here is the link for the solution:

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

Thanks to Daniel.

like image 60
Dhruv Bansal Avatar answered Jan 27 '26 14:01

Dhruv Bansal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!