KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > component > UIDateInput


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.faces.core.component;
6
7 import java.util.* ;
8 import javax.faces.context.FacesContext;
9 import javax.faces.validator.Validator ;
10 /**
11  * Wed, Dec 22, 2003 @ 23:14
12  * @author: Tuan Nguyen
13  * @email: tuan08@users.sourceforge.net
14  * @version: $Id: UIDateInput.java,v 1.2 2004/10/16 21:13:50 tuan08 Exp $
15  */

16 public class UIDateInput extends UIInput {
17   public static final String JavaDoc COMPONENT_FAMILY = "org.exoplatform.faces.core.component.UIDateInput" ;
18   public static final int TEXT = 0;
19   public static final int PASSWORD = 1;
20
21   protected GregorianCalendar calendar_ ;
22   private int minYearRange_ = 2000 ;
23   private int maxYearRange_ = 2010 ;
24
25   public UIDateInput(String JavaDoc name, Date date) {
26     setId(name) ;
27     name_ = name ;
28     calendar_ = new GregorianCalendar() ;
29     calendar_.set(Calendar.HOUR_OF_DAY, 23) ;
30     calendar_.set(Calendar.MINUTE, 59) ;
31     maxYearRange_ = calendar_.get(Calendar.YEAR) ;
32     setValue(date);
33     editable_ = true ;
34     setRendererType("DateInputRenderer") ;
35   }
36   
37   public String JavaDoc getFamily() { return COMPONENT_FAMILY ; }
38   
39   final public Date getValue() { return calendar_.getTime() ; }
40   final public UIDateInput setValue(Date date) {
41     if(date != null) calendar_.setTime(date) ;
42     return this ;
43   }
44   
45   public Calendar getCalendar() { return calendar_ ; }
46   
47   public int getMinYearRange() { return minYearRange_ ; }
48   public void setMinYearRange(int year) { minYearRange_ = year ; }
49   
50   public int getMaxYearRange() { return maxYearRange_ ; }
51   public void setMaxYearRange(int year) { maxYearRange_ = year ; }
52   
53   public UIDateInput addValidator(Validator validator) {
54     addComponentValidator(validator) ;
55     return this ;
56   }
57   
58   public UIDateInput addValidator(Class JavaDoc clazz) {
59     addComponentValidator(clazz) ;
60     return this ;
61   }
62   
63   final public void processValidators(FacesContext context) {
64     processValidators(context, calendar_) ;
65   }
66 }
Popular Tags