Author: nbelaevski
Date: 2008-04-18 11:57:36 -0400 (Fri, 18 Apr 2008)
New Revision: 7945
Modified:
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
Log:
http://jira.jboss.com/jira/browse/RF-3142
Modified:
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
---
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-04-18
15:54:06 UTC (rev 7944)
+++
branches/3.1.x/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-04-18
15:57:36 UTC (rev 7945)
@@ -55,9 +55,7 @@
import org.richfaces.model.CalendarDataModelItem;
import org.richfaces.renderkit.CalendarRendererBase;
-import java.text.DateFormat;
-
// import org.richfaces.renderkit.html.BaseGradient.Data;
/**
@@ -66,6 +64,29 @@
*/
public abstract class UICalendar extends UIInput implements AjaxComponent {
+ /**
+ * firstWeekDay
+ * Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
+ */
+ private int _firstWeekDay = getDefaultFirstWeekDay();
+ /**
+ * Flag indicated what firstWeekDay is set.
+ */
+ private boolean _firstWeekDaySet = false;
+
+ /**
+ * minDaysInFirstWeek
+ * Gets what the minimal days required in the first week of the year
+ are; e.g., if the first week is defined as one that contains the first
+ day of the first month of a year, this method returns 1. If the
+ minimal days required must be a full week, this method returns 7.
+ */
+ private int _minDaysInFirstWeek = getDefaultMinDaysInFirstWeek();
+ /**
+ * Flag indicated what minDaysInFirstWeek is set.
+ */
+ private boolean _minDaysInFirstWeekSet = false;
+
public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
private static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
@@ -205,12 +226,6 @@
public abstract void setShowApplyButton(boolean showApplyButton);
- public abstract int getFirstWeekDay();
- public abstract void setFirstWeekDay(int firstWeekDay);
-
- public abstract int getMinDaysInFirstWeek();
- public abstract void setMinDaysInFirstWeek(int minDaysInFirstWeek);
-
// TODO onclick add users onclick
// currentDate processing -------------------------------------------------
@@ -621,4 +636,95 @@
return getCalendar().getMinimalDaysInFirstWeek();
}
+ /**
+ * Gets what the minimal days required in the first week of the year
+ are; e.g., if the first week is defined as one that contains the first
+ day of the first month of a year, this method returns 1. If the
+ minimal days required must be a full week, this method returns 7.
+ * Setter for minDaysInFirstWeek
+ * @param minDaysInFirstWeek - new value
+ */
+ public void setMinDaysInFirstWeek( int __minDaysInFirstWeek ){
+ this._minDaysInFirstWeek = __minDaysInFirstWeek;
+ this._minDaysInFirstWeekSet = true;
+ }
+
+
+ /**
+ * Gets what the minimal days required in the first week of the year
+ are; e.g., if the first week is defined as one that contains the first
+ day of the first month of a year, this method returns 1. If the
+ minimal days required must be a full week, this method returns 7.
+ * Getter for minDaysInFirstWeek
+ * @return minDaysInFirstWeek value from local variable or value bindings
+ */
+ public int getMinDaysInFirstWeek( ){
+ if(this._minDaysInFirstWeekSet){
+ return this._minDaysInFirstWeek;
+ }
+ ValueBinding vb = getValueBinding("minDaysInFirstWeek");
+ if (vb != null) {
+ Integer value = (Integer) vb.getValue(getFacesContext());
+ if (null == value) {
+ return getDefaultMinDaysInFirstWeek();
+ }
+ return (value.intValue());
+ } else {
+ return getDefaultMinDaysInFirstWeek();
+ }
+ }
+ /**
+ * Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
+ * Setter for firstWeekDay
+ * @param firstWeekDay - new value
+ */
+ public void setFirstWeekDay( int __firstWeekDay ){
+ this._firstWeekDay = __firstWeekDay;
+ this._firstWeekDaySet = true;
+ }
+
+
+ /**
+ * Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
+ * Getter for firstWeekDay
+ * @return firstWeekDay value from local variable or value bindings
+ */
+ public int getFirstWeekDay( ){
+ if(this._firstWeekDaySet){
+ return this._firstWeekDay;
+ }
+ ValueBinding vb = getValueBinding("firstWeekDay");
+ if (vb != null) {
+ Integer value = (Integer) vb.getValue(getFacesContext());
+ if (null == value) {
+ return getDefaultFirstWeekDay();
+ }
+ return (value.intValue());
+ } else {
+ return getDefaultFirstWeekDay();
+ }
+ }
+
+ public Object saveState(FacesContext context) {
+ return new Object [] {
+ super.saveState(context),
+
+ new Integer(_firstWeekDay),
+ new Boolean(_firstWeekDaySet),
+
+ new Integer(_minDaysInFirstWeek),
+ new Boolean(_minDaysInFirstWeekSet)
+ };
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object[] states = (Object[]) state;
+ super.restoreState(context, states[0]);
+
+ _firstWeekDay = ((Integer)states[1]).intValue();
+ _firstWeekDaySet = ((Boolean)states[2]).booleanValue();
+
+ _minDaysInFirstWeek = ((Integer)states[3]).intValue();
+ _minDaysInFirstWeekSet = ((Boolean)states[4]).booleanValue();
+ }
}