1 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 16 public class UIDateInput extends UIInput { 17 public static final String 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 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 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 clazz) { 59 addComponentValidator(clazz) ; 60 return this ; 61 } 62 63 final public void processValidators(FacesContext context) { 64 processValidators(context, calendar_) ; 65 } 66 } | Popular Tags |