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 e-mail using RemoteCommand

We will now take a look at how to invoke server-side logic from JavaScript code using RemoteCommand. First we will check the e-mail format on client side using JavaScript, and then invoke server-side logic to check if the user provided e-mail already in use or not. Perform the following steps:

  1. Create a method using following code in the UserController managed bean to check whether the given e-mail is already in use or not:
    @ManagedBean @RequestScoped public class UserController { public void checkEmailExists() { String email = this.registrationUser.getEmail(); if("admin@gmail.com".equals(email) || "test@gmail.com".equals(email)) { String msg = "Email ["+email+"] already in use."; FacesContext.getCurrentInstance().addMessage("registrationForm:email", ...

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