O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – using CAPTCHA for user registration

Now, let us see how to use the PrimeFaces Captcha component for user registration.

  1. Create a user registration form with the Captcha component:
    <h:form>  
      <p:messages showDetail="true" autoUpdate="true"/>  
      <h:panelGrid columns="2">
        <h:outputLabel value="EmailId" />
        <p:inputText value="#{userController.registerUser.emailId}" required="true" label="EmailId"/>
    
        <h:outputLabel value="Password" />
        <p:password value="#{userController.registerUser.password}" required="true" label="Password"/>
    
        <p:captcha label="Captcha" theme="red"/>
        <h:outputLabel value="" />
      
        <p:commandButton value="Register" ajax="false" actionListener="#{userController.doRegister}" />
    
      </h:panelGrid>
    </h:form>

What just happened?

We have ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required