Author: vbaranov
Date: 2008-04-22 09:44:51 -0400 (Tue, 22 Apr 2008)
New Revision: 8059
Modified:
trunk/ui/calendar/src/main/config/component/calendar.xml
trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
http://jira.jboss.com/jira/browse/RF-3106
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2008-04-22 12:55:08 UTC (rev
8058)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2008-04-22 13:44:51 UTC (rev
8059)
@@ -127,7 +127,7 @@
</property>
<property>
- <name>resetTimeOnDateChange</name>
+ <name>resetTimeOnDateSelect</name>
<classname>boolean</classname>
<description>If value is true then calendar should change time to defaultTime
for newly-selected dates.</description>
<defaultvalue>false</defaultvalue>
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
12:55:08 UTC (rev 8058)
+++ trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-04-22
13:44:51 UTC (rev 8059)
@@ -70,6 +70,21 @@
public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
private static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
+
+ /**
+ * Default value of "defaultTime" attribute
+ */
+ private static String DEFAULT_TIME_VALUE = "hours:12,minutes:0";
+
+ /**
+ * Constant "hours"
+ */
+ private static String HOURS_VALUE = "hours";
+
+ /**
+ * Constant "minutes"
+ */
+ private static String MINUTES_VALUE = "minutes";
public static final String AJAX_MODE = "ajax";
@@ -109,9 +124,9 @@
public abstract void setDefaultTime(Object defaultTime);
- public abstract boolean isResetTimeOnDateChange();
+ public abstract boolean isResetTimeOnDateSelect();
- public abstract void setResetTimeOnDateChange(boolean resetTimeOnDateChange);
+ public abstract void setResetTimeOnDateSelect(boolean resetTimeOnDateSelect);
public abstract Object getMonthLabels();
@@ -289,41 +304,35 @@
}
return result;
}
-
+
/**
- * Returns hours from "defaultTime" attribute
- * @return hours from "defaultTime" attribute
+ * Returns hours and minutes from "defaultTime" attribute as a String
+ * with special format:
+ * hours:"value_hours",minutes:"value_minutes"
+ *
+ * @return hours and minutes from "defaultTime" attribute
*/
- public int getDefaultTimeHours() {
+ public String getPreparedDefaultTime() {
Date date = getFormattedDefaultTime();
if (date == null) {
- return 0;
+ return DEFAULT_TIME_VALUE;
}
-
- Calendar calendar = getCalendar();
- calendar.setTime(date);
-
- return calendar.get(Calendar.HOUR_OF_DAY);
- }
-
- /**
- * Returns minutes from "defaultTime" attribute
- * @return minutes from "defaultTime" attribute
- */
- public int getDefaultTimeMinutes() {
- Date date = getFormattedDefaultTime();
+ StringBuilder result = new StringBuilder();
- if (date == null) {
- return 0;
- }
-
Calendar calendar = getCalendar();
calendar.setTime(date);
+
+ result.append(HOURS_VALUE).append(":");
+ result.append(calendar.get(Calendar.HOUR_OF_DAY));
+ result.append(",");
+ result.append(MINUTES_VALUE).append(":");
+ result.append(calendar.get(Calendar.MINUTE));
+
+ return result.toString();
+
+ }
- return calendar.get(Calendar.MINUTE);
- }
-
protected void validateValue(FacesContext context, Object newValue) {
// TODO nick - nick - do we need this?
// store converted value in submitted value to ease client-side code's
Modified:
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2008-04-22
12:55:08 UTC (rev 8058)
+++
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2008-04-22
13:44:51 UTC (rev 8059)
@@ -157,6 +157,18 @@
return null;
}
}
+
+ /**
+ * Returns hours and minutes from "defaultTime" attribute as a String with
+ * special format: hours:"value_hours",minutes:"value_minutes"
+ *
+ * @param calendar - UICalendar
+ *
+ * @return hours and minutes from "defaultTime" attribute
+ */
+ public String getPreparedDefaultTime(UICalendar calendar) {
+ return calendar.getPreparedDefaultTime();
+ }
/**
* Overloads getFormattedValue to take a advantage of a previously
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2008-04-22
12:55:08 UTC (rev 8058)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2008-04-22
13:44:51 UTC (rev 8059)
@@ -188,7 +188,9 @@
showFooter:#{component.attributes['showFooter']},
showWeeksBar:#{component.attributes['showWeeksBar']},
showWeekDaysBar:#{component.attributes['showWeekDaysBar']},
- showApplyButton:#{component.attributes['showApplyButton']}
+ showApplyButton:#{component.attributes['showApplyButton']},
+ resetTimeOnDateChange:#{component.attributes['resetTimeOnDateChange']} ,
+ defaultTime: #{this:getPreparedDefaultTime(component)}
<f:call name="writeLabels" />