1 3 4 package com.sun.j2ee.blueprints.bpcatalog.validator; 5 6 import javax.faces.component.UIComponent; 7 import javax.faces.context.FacesContext; 8 import javax.faces.application.FacesMessage; 9 import javax.faces.validator.ValidatorException; 10 import javax.faces.validator.LongRangeValidator; 11 import javax.faces.validator.Validator; 12 13 14 public class ValidatorBean { 15 16 private String userName = null; 17 private String response = null; 18 private String color = null; 19 private int bigNumber = 0; 20 private int smallNumber = 0; 21 22 23 public ValidatorBean() {} 24 25 26 public void setUserName(String userName) { 27 this.userName = userName; 28 } 29 30 31 public String getUserName() { 32 return userName; 33 } 34 35 public int getBigNumber() { 36 return bigNumber; 37 } 38 39 public void setBigNumber(int bigNumber) { 40 this.bigNumber = bigNumber; 41 } 42 43 public int getSmallNumber() { 44 return smallNumber; 45 } 46 47 public void setSmallNumber(int smallNumber) { 48 this.smallNumber = smallNumber; 49 } 50 51 public void setColor(String color) { 52 this.color = color; 53 } 54 55 public String getColor() { 56 return color; 57 } 58 59 public String getResponse() { 60 return "The User name is now " + userName + "."; 61 } 62 63 64 public void validate(FacesContext context, 65 UIComponent component, 66 Object value) throws ValidatorException { 67 68 if ((context == null) || (component == null)) { 69 throw new NullPointerException (); 70 } 71 if (value != null) { 72 if (((String )value).equals("blueprints")) { 73 throw new ValidatorException(new FacesMessage("blueprints is invalid")); 74 } 75 } 76 } 77 } 78 79 | Popular Tags |