Email Validator


@FacesValidator(value="SubmissionJavaBean")

public class SubmissionJavaBean implements Validator{

//declare variables, add getters and setters

....
....

public void validate(FacesContext facesContext, UIComponent uIComponent,

Object object) throws ValidatorException {

// @FacesValidator(value="SubscriptionBean") is needed up top

....
....



// 2012.02.14.10.00.AM

EmailConfirm = (String) object;

EmailAddress = (String) object;

// TODO modify built-in pattern to add below characters within Xpages
// 2012.02.14.10.23.AM

Pattern p = Pattern.compile(".+@.+\\.[a-z]+");// \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

Matcher cm = p.matcher(EmailConfirm);

Matcher em = p.matcher(EmailAddress);

boolean matchCFound = cm.matches();

boolean matchEFound = em.matches();


if (!matchCFound || !matchEFound) {


FacesMessage message = new FacesMessage();

// load message to Xpages form
// 2012.02.14.9.40.AM

message.setSummary("Invalid Email ID");

throw new ValidatorException(message);


}


}



}//end of program
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...