package com.dokoll.solutions.inc.developement.Utils; /** * Created: 2013.10.14.10.02.AM * Testing FacesMessage field against static value comparison */ import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; /** * @author Dököll Solutions, Inc. * @version 2013.10.14.10.02.AM * */ @FacesValidator(value = "ValidationJavaBean") public class ValidationJavaBean implements Validator { private String UserID; private String message; static String USERID = "AlienHouse"; /** * @return the userID */ public String getUserID() { return UserID; } /** * @param userID the userID to set */ public void setUserID(String userID) { UserID = userID; } /** * @return the message */ public String getMessage() { return message; } /** * @param message the message to set */ public void setMessage(String message) { this.message = message; } public ValidationJavaBean() { //... } //validate component public void validate(FacesContext facesContext, UIComponent uIComponent, Object object) throws ValidatorException { //initialize object UserID = (String) object; //... boolean matchUserIDFound = USERID.equalsIgnoreCase(UserID); //load message where match is not found if (!matchUserIDFound) { FacesMessage message = new FacesMessage(); //send message to Xpages form message.setDetail("Invalid UserID"); throw new ValidatorException(message); } } } //... //end of program //... /** * Created: 2013.10.14.10.22.AM * Testing FacesMessage field against static value comparison */ package com.dokoll.solutions.inc.developement.Utils; /** * @author Dököll Solutions, Inc. * @version 2013.10.14.10.22.AM * */ public @interface FacesValidator { String value(); } //... //end of program