When the email address is invalid the message displayed is "Invalid email.Invalid email.". I know that the message has two parts: summary and a details. I need both of these, but I want to have different info in each. How can I change the message to display "Invalid email: Please enter a valid email address" instead?
<p:messages showDetail="true" autoUpdate="true" closable="true" />
<h:panelGrid columns="2">
<h:outputText value="#{label.email}: *" />
<p:inputText required="true" value="#{userWizard.emailAddress}"
validatorMessage="#{label.invalidEmail}" label="#{label.email}">
<f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$">
</f:validateRegex>
</p:inputText>
</h:panelGrid>
This is not possible with
validatorMessage(neitherconverterMessagenorrequiredMessage). The value will be used as both the summary and the detail.You'd need to homegrow a custom validator instead wherein you can construct the
FacesMessagewith the both parts yourself. Assuming that you've next to thelabel.emailalso alabel.email_detailwhich represents the message detail, then it should look something like this:(note that I adapted the email regexp for better preparation on world domination; non-latin characters like Chinese, Hebrew, Cyrillic, etc are namely allowed in domain names and thus also email addresses since the new IANA decision in 2010)
which is then to be used as