Author: akushunin
Date: 2007-07-31 12:05:01 -0400 (Tue, 31 Jul 2007)
New Revision: 1959
Modified:
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
Log:
TODO tasks were made
Some unused methods deleted
Modified:
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-31
15:58:47 UTC (rev 1958)
+++
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-31
16:05:01 UTC (rev 1959)
@@ -139,7 +139,8 @@
ev.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
ev.queue();
- //TODO nick - nick - queue this event when ValueChangeEvent is queued?
+ // TODO nick - nick - queue this event when ValueChangeEvent is
+ // queued?
new AjaxEvent(component).queue();
}
@@ -193,8 +194,7 @@
options.put("calendar", JSReference.THIS);
options.put("single", JSReference.TRUE);
// ajax single
- // options.put("control", new JSReference(JSReference.THIS.toScript(),
- // "id"));
+ // options.put("control", new
JSReference(JSReference.THIS.toScript(),"id"));
String oncomplete = AjaxRendererUtils.getAjaxOncomplete(calendar);
JSFunctionDefinition oncompleteDefinition = new JSFunctionDefinition();
@@ -220,32 +220,33 @@
public String getInputValue(FacesContext context, UIComponent component) {
UICalendar input = (UICalendar) component;
- //TODO nick - nick - can contain either Date or String instance
- String value = (String) input.getSubmittedValue();
+ // XXX nick - nick - can contain either Date or String instance
+
+ Object value = input.getSubmittedValue();
+ Object curVal = input.getValue();
if (value == null) {
- Object curVal = input.getValue();
+
DateTimeConverter converter = new DateTimeConverter();
converter.setPattern(input.getDatePattern());
converter.setLocale(input.getLocale());
- // converter.setTimeZone(input.getTimeZone());
- // Converter converter =
- // SelectUtils.getConverterForProperty(context, input, "value");
+ converter.setTimeZone(input.getTimeZone());
+ return converter.getAsString(context, input, curVal);
+ }
+ if (value instanceof Date) {
- //TODO nick - kaa - how could converter be null here?
- if (converter != null) {
- value = converter.getAsString(context, input, curVal);
- } else {
- if (curVal == null) {
- value = "";
- } else {
- value = curVal.toString();
- }
- }
+ DateTimeConverter converter = new DateTimeConverter();
+ converter.setPattern(input.getDatePattern());
+ converter.setLocale(input.getLocale());
+ return converter.getAsString(context, input, value);
}
- if (value == null) {
- value = "";
+ if (value instanceof String) {
+
+ Converter converter = SelectUtils.getConverterForProperty(context,
+ input, "value");
+ return converter.getAsString(context, input, value);
+
}
- return value;
+ return null;
}
public void writeSymbols(FacesContext facesContext, UICalendar calendar)
@@ -266,9 +267,9 @@
}
}
- private static String[] shiftDates(int minimum,
+ private static String[] shiftDates(int firstDayOfWeek, int minimum,
int maximum, String[] labels) {
- if (minimum == 0 && (maximum - minimum + 1 == labels.length)) {
+ if (minimum == 0) {
return labels;
}
@@ -286,15 +287,14 @@
Calendar cal = calendar.getCalendar();
int maximum = cal.getActualMaximum(Calendar.DAY_OF_WEEK);
int minimum = cal.getActualMinimum(Calendar.DAY_OF_WEEK);
-
- // .getInstance(locale) changed to new DateFormatSymbols(locale) by
- // Alexej Kushunin ;
+ int firstDayOfWeek = cal.getFirstDayOfWeek();
+
DateFormatSymbols symbols = new DateFormatSymbols(locale);
String[] weekDayLabels = ComponentUtil.asArray(calendar
.getWeekDayLabels());
if (weekDayLabels == null) {
weekDayLabels = symbols.getWeekdays();
- weekDayLabels = shiftDates(minimum, maximum,
+ weekDayLabels = shiftDates(firstDayOfWeek, minimum, maximum,
weekDayLabels);
}
@@ -302,26 +302,19 @@
.getWeekDayLabelsShort());
if (weekDayLabelsShort == null) {
weekDayLabelsShort = symbols.getShortWeekdays();
- weekDayLabelsShort = shiftDates(minimum, maximum,
+ weekDayLabelsShort = shiftDates(firstDayOfWeek, minimum, maximum,
weekDayLabelsShort);
}
- int monthMax = cal.getActualMaximum(Calendar.MONTH);
- int monthMin = cal.getActualMinimum(Calendar.MONTH);
-
String[] monthLabels = ComponentUtil.asArray(calendar.getMonthLabels());
if (monthLabels == null) {
monthLabels = symbols.getMonths();
- monthLabels = shiftDates(monthMin, monthMax,
- monthLabels);
}
String[] monthLabelsShort = ComponentUtil.asArray(calendar
.getMonthLabelsShort());
if (monthLabelsShort == null) {
monthLabelsShort = symbols.getShortMonths();
- monthLabelsShort = shiftDates(monthMin, monthMax,
- monthLabelsShort);
}
map.put(WEEK_DAY_LABELS, weekDayLabels);