jsf-2primefaces

Password matching message in primefaces


I copied the exact code from this Primefaces http://blog.primefaces.org/?p=1512 blog about easy password validation

<h:outputLabel for="pwd1" value="Password 1: *" />
                    <p:password id="pwd1" value="#{registerMB.password}"
                        feedback="false" match="pwd2" label="Password 1" required="true" />

                    <h:outputLabel for="pwd2" value="Password 2: *" />
                    <p:password id="pwd2" value="#{registerMB.password}"
                        feedback="false" label="Password 2" required="true" />

                    <f:facet name="footer">
                        <p:commandButton value="Register" action="/pages/public/login" />
                        <p:commandButton value="Cancel" immediate="true"
                            action="/pages/public/login" />
                    </f:facet>

Validation works but I am only able to get the Validation Error. The message Password 1 should match Password 2 is never displayed. Is there anymore configuration for this?

I have Primefaces 3.4.1 downloaded


Solution

  • add <p:messages id="messages" showDetail="true" autoUpdate="true"/>

    just like int Primefaecs Password Showcase

    <h:form id="form">  
    <p:panel header="Match Mode">  
        <p:messages id="messages" showDetail="true" autoUpdate="true"/>  
    
        <h:panelGrid columns="2" id="matchGrid">                     
            <h:outputLabel for="pwd1" value="Password 1: *" />  
            <p:password id="pwd1" value="#{passwordBean.password5}" match="pwd2" label="Password 1" required="true"/>  
    
            <h:outputLabel for="pwd2" value="Password 2: *" />  
            <p:password id="pwd2" value="#{passwordBean.password5}" label="Password 2" required="true"/>  
        </h:panelGrid>  
    
        <p:commandButton id="saveButton" update="matchGrid" value="Save" />  
    </p:panel>  
    </h:form>