Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package np.com.drose.parkgarau.validator; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; import org.apache.commons.lang3.StringUtils; /** *{Insert class description here} * @version $Revision: 1.1.1.1 $ * @since Build {insert version here} (MM YYYY) * @author bibek */ @FacesValidator public class Codevalidator implements Validator { @Override public void validate(FacesContext fc, UIComponent uic, Object o) throws ValidatorException { if (StringUtils.containsWhitespace(o.toString())) { FacesMessage msg = new FacesMessage("Incorrect input provided", "The input must not have space"); msg.setSeverity(FacesMessage.SEVERITY_ERROR); throw new ValidatorException(msg); } } }