Author: nbelaevski
Date: 2008-04-22 21:17:56 -0400 (Tue, 22 Apr 2008)
New Revision: 8085
Modified:
trunk/ui/calendar/src/main/config/component/calendar.xml
trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
Log:
http://jira.jboss.com/jira/browse/RF-3122
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2008-04-22 23:42:59 UTC (rev
8084)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2008-04-23 01:17:56 UTC (rev
8085)
@@ -596,7 +596,6 @@
<name>firstWeekDay</name>
<classname>int</classname>
<description>Gets what the first day of the week is; e.g., SUNDAY in the U.S.,
MONDAY in France. Default value is
"getDefaultFirstWeekDay()".</description>
- <defaultvalue>getDefaultFirstWeekDay()</defaultvalue>
</property>
<property>
<name>minDaysInFirstWeek</name>
@@ -607,7 +606,6 @@
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. Default value is
"getDefaultMinDaysInFirstWeek()".
</description>
- <defaultvalue>getDefaultMinDaysInFirstWeek()</defaultvalue>
</property>
</component>
Modified: trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-04-22
23:42:59 UTC (rev 8084)
+++ trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-04-23
01:17:56 UTC (rev 8085)
@@ -21,6 +21,9 @@
package org.richfaces.component;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -57,16 +60,35 @@
import org.richfaces.model.CalendarDataModelItem;
import org.richfaces.renderkit.CalendarRendererBase;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-
/**
* JSF component class
*
*/
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 = 0;
+ /**
+ * 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 = 0;
+ /**
+ * 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";
@@ -234,13 +256,7 @@
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 -------------------------------------------------
@@ -739,4 +755,95 @@
protected int getDefaultMinDaysInFirstWeek() {
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();
+ }
}