KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > bpcatalog > validator > ValidatorBean


1 /* Copyright 2005 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
2 $Id: ValidatorBean.java,v 1.1 2005/03/08 22:08:46 gmurray71 Exp $ */

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 JavaDoc userName = null;
17     private String JavaDoc response = null;
18     private String JavaDoc color = null;
19     private int bigNumber = 0;
20     private int smallNumber = 0;
21
22
23     public ValidatorBean() {}
24
25
26     public void setUserName(String JavaDoc userName) {
27         this.userName = userName;
28     }
29
30
31     public String JavaDoc 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 JavaDoc color) {
52         this.color = color;
53     }
54
55     public String JavaDoc getColor() {
56         return color;
57     }
58
59     public String JavaDoc getResponse() {
60         return "The User name is now " + userName + ".";
61     }
62
63
64     public void validate(FacesContext context,
65                          UIComponent component,
66                          Object JavaDoc value) throws ValidatorException {
67
68         if ((context == null) || (component == null)) {
69             throw new NullPointerException JavaDoc();
70         }
71         if (value != null) {
72            if (((String JavaDoc)value).equals("blueprints")) {
73                throw new ValidatorException(new FacesMessage("blueprints is invalid"));
74            }
75         }
76     }
77 }
78
79
Popular Tags