Search code examples
primefacesprimefaces-extensions

pe:inputPhone validatorMessage attribute is ignored


I have this code here for the PrimeFaces Extensions pe:inputPhone in my project. I want to have a custom validator message when the phone number is not valid. However the validatorMessage attribute is not working and the standard one is always showing. Does anyone know how I could solve it?

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:ic="http://ivyteam.ch/jsf/component"
    xmlns:p="http://primefaces.org/ui"
    xmlns:pe="http://primefaces.org/ui/extensions">
<h:body>
    <ui:composition template="/layouts/frame-8.xhtml">
        <ui:define name="title">UiTesting</ui:define>
        <ui:define name="content">
            <h:outputStylesheet name="testing.css" />
            <h:form id="form">
            <p:growl/>
                <p:messages />
                
                <pe:inputPhone value="" id="telefon" initialCountry="de" widgetVar="phonenumber"
                requiredMessage="Phone required"
                validatorMessage="Number not valid"
                required="true" onchange="this.value=PF('phonenumber').getNumber();"
                data-cy="phonenumber" formatOnDisplay="false">
                </pe:inputPhone>

            </h:form>
        </ui:define>
    </ui:composition>
</h:body>
</html>

Solution

  • Thanks for reporting this issue. It will be fixed in PrimeFaces Extensions 11.0.3.

    See also:

    Please note that you will need to add the libphonenumber dependency to your project in order to be able to validate phone numbers.

    <dependency>
        <groupId>com.googlecode.libphonenumber</groupId>
        <artifactId>libphonenumber</artifactId>
        <version>...</version>
    </dependency>
    

    Until 11.0.3 is released, you could create a custom validator and use that as a workaround.