Author: vbaranov
Date: 2008-04-30 07:59:33 -0400 (Wed, 30 Apr 2008)
New Revision: 8373
Modified:
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
Log:
http://jira.jboss.com/jira/browse/RF-3186
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-30
11:42:41 UTC (rev 8372)
+++
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2008-04-30
11:59:33 UTC (rev 8373)
@@ -139,8 +139,10 @@
// in case the converter hasn't been set, try to use default DateTimeConverter
if (converter == null) {
- converter = createDefaultConverter(calendar);
+ converter = createDefaultConverter();
}
+ setupDefaultConverter(converter, calendar);
+
return converter.getAsObject(context, component, newValue);
}
@@ -197,7 +199,7 @@
if (converter == null) {
// If there is a converter attribute, use it to to ask application
- // instance for a converter with this identifer.
+ // instance for a converter with this identifier.
converter = calendar.getConverter();
}
@@ -221,10 +223,11 @@
// assume the model type to be String.
if (converter == null) {
// in case the converter hasn't been set, try to use default DateTimeConverter
- converter = createDefaultConverter(calendar);
+ converter = createDefaultConverter();
}
}
-
+ setupDefaultConverter(converter, calendar);
+
return converter.getAsString(context, calendar, currentValue);
}
@@ -250,13 +253,31 @@
*
* @return created converter
*/
- protected static Converter createDefaultConverter(UICalendar calendar) {
- DateTimeConverter defaultConverter = new DateTimeConverter();
- defaultConverter.setPattern(calendar.getDatePattern());
- defaultConverter.setLocale(calendar.getAsLocale(calendar.getLocale()));
- defaultConverter.setTimeZone(calendar.getTimeZone());
+ protected static Converter createDefaultConverter() {
+ return new DateTimeConverter();
+ }
+
+ /**
+ * Setup the default converter provided by JSF API
+ * (<code>DateTimeConverter</code>) with the component settings
+ * @param converter
+ * @param calendar
+ * @return
+ */
+ protected static Converter setupDefaultConverter(Converter converter, UICalendar
calendar) {
+ // skip id converter is null
+ if(converter == null) {
+ return null;
+ }
- return defaultConverter;
+ if(converter instanceof DateTimeConverter) {
+ DateTimeConverter defaultConverter = (DateTimeConverter) converter;
+ defaultConverter.setPattern(calendar.getDatePattern());
+ defaultConverter.setLocale(calendar.getAsLocale(calendar.getLocale()));
+ defaultConverter.setTimeZone(calendar.getTimeZone());
+ }
+
+ return converter;
}
protected void doDecode(FacesContext context, UIComponent component) {