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 – validate the UserName using AJAX listeners

Let's add AJAX event listener keyup event to the UserName input field so that as you type, it will check if the username entered is already in use or not.

  1. Create viewAjaxListener.xhtml with registration form to validate the UserName using AJAX Listener as follows:
    <h:form id="registrationForm"> <p:panel header="Registration Form" style="width: 800px;"> <h:panelGrid columns="3"> <p:outputLabel value="UserName:*"/> <p:inputText id="userName" value="#{userController.registrationUser.userName}" required="true" label="UserName"> <p:ajax event="keyup" listener="#{userController.checkUserNamesExists()}" update="userNameMsg"/> </p:inputText> <p:message id="userNameMsg" for="userName"/> <p:outputLabel ...

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