Friday 22 February 2013

ADF : Name validator

## Name validator

public void NameValidation_Normal(FacesContext facesContext, UIComponent uIComponent, Object object) {
       String value = (String)object;
       if ((value == null) || value.length() == 0) {
           return;
       }
       

       String expression = "[A-Za-z0-9]*";
       CharSequence inputStr = value;
       Pattern pattern = Pattern.compile(expression);
       Matcher matcher = pattern.matcher(inputStr);
       String error = "Special character not allowed";
       if (matcher.matches()) {
       } else {

           throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, error, null));
       }
   }
























































No comments:

Post a Comment