Problem with "match" attribute of a text field

Asked

Viewed 212 times

0

I’m using the attribute match of a <p:password/>, but it doesn’t work properly.

<p:password id="senha"/>
<p:password match="senha"/>

When I send the form via commandButton, an error message arises, saying that passwords do not match, even though I have placed the same characters.
How can I fix it?

  • You receive the values in your Controller, if received could post the method you receive? Have you tried to see if they are coming null? Could post which error gives?

  • I don’t get anything in control, I mean, I don’t attribute any attributes to p:password with the match. Primefaces does not do this automatically?

  • No, it does not, you have to send to your Controller, see here, you need to set in the value field your Managedbean.Password. Considering "Password" an attribute

  • Ah, just to confirm: both use the same attribute as value?

  • Yes, from a read in the article I commented on, it’s always good to read the Primefaces Showcase

1 answer

1

Follow @Patrick for example

<h:panelGrid columns="2" id="matchGrid" cellpadding="5">                   
    <h:outputLabel for="pwd1" value="Password 1: *" />
    <p:password id="pwd1" value="#{passwordView.password5}" match="pwd2" label="Password 1" required="true" />

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

Actually the API itself checks with the match what is missing from your code is the attribute the password will receive in your View

  • Didn’t work, keeps making the same mistake.

  • how is the code in your View and your XHTML?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.