The included patch file adds short month names to the popup calendar from the 
current locale in Java.
Index: tomahawk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java
===================================================================
--- tomahawk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java	(revision 332213)
+++ tomahawk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java	(working copy)
@@ -204,12 +204,13 @@
         DateFormatSymbols symbols = new DateFormatSymbols(currentLocale);
 
         HtmlCalendarRenderer.addScriptAndCSSResources(facesContext, symbols, 
-                HtmlCalendarRenderer.mapMonths(symbols), Calendar.getInstance(currentLocale).getFirstDayOfWeek(),
+                HtmlCalendarRenderer.mapMonths(symbols), HtmlCalendarRenderer.mapShortMonths(symbols), Calendar.getInstance(currentLocale).getFirstDayOfWeek(),
                 uiComponent);
 
         String localizedLanguageScript = HtmlCalendarRenderer.getLocalizedLanguageScript(
                 							symbols,
                 							HtmlCalendarRenderer.mapMonths(symbols),
+                							HtmlCalendarRenderer.mapShortMonths(symbols),
                 							Calendar.getInstance(currentLocale).getFirstDayOfWeek(),
                 							null);
 
Index: tomahawk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
===================================================================
--- tomahawk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java	(revision 332213)
+++ tomahawk/src/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java	(working copy)
@@ -98,11 +98,12 @@
 
         String[] weekdays = mapShortWeekdays(symbols);
         String[] months = mapMonths(symbols);
+        String[] shortMonths = mapShortMonths(symbols);
 
         if(inputCalendar.isRenderAsPopup())
         {
             if(inputCalendar.isAddResources())
-                addScriptAndCSSResources(facesContext, symbols, months,
+                addScriptAndCSSResources(facesContext, symbols, months, shortMonths,
 	                    timeKeeper.getFirstDayOfWeek(),inputCalendar);
 
             String dateFormat = CalendarDateTimeConverter.createJSPopupFormat(facesContext,
@@ -151,7 +152,7 @@
 
 	            writer.startElement(HTML.SCRIPT_ELEM, component);
 	            writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR,HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
-	            writer.writeText(getLocalizedLanguageScript(symbols, months,
+	            writer.writeText(getLocalizedLanguageScript(symbols, months, shortMonths,
 	                    timeKeeper.getFirstDayOfWeek(),inputCalendar),null);
                 writer.writeText(getScriptBtn(facesContext, inputCalendar,
                         dateFormat,inputCalendar.getPopupButtonString()),null);
@@ -252,7 +253,7 @@
      * Used by the x:inputDate renderer : HTMLDateRenderer
      * @throws IOException
      */
-    static public void addScriptAndCSSResources(FacesContext facesContext, DateFormatSymbols symbols, String[] months, int firstDayOfWeek,
+    static public void addScriptAndCSSResources(FacesContext facesContext, DateFormatSymbols symbols, String[] months, String[] shortMonths, int firstDayOfWeek,
                                                 UIComponent uiComponent) throws IOException{
         // check to see if javascript has already been written (which could happen if more than one calendar on the same page)
         if (facesContext.getExternalContext().getRequestMap().containsKey(JAVASCRIPT_ENCODED))
@@ -270,7 +271,7 @@
         StringBuffer imageScript = new StringBuffer();
         appendImageDirectory(imageScript, facesContext);
         addresource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, imageScript.toString());
-        addresource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, getLocalizedLanguageScript(symbols,months,firstDayOfWeek,
+        addresource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, getLocalizedLanguageScript(symbols,months,shortMonths,firstDayOfWeek,
                                         uiComponent));
         addresource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, HtmlCalendarRenderer.class, "popcalendar.js");
 
@@ -297,7 +298,7 @@
     }
 
     public static String getLocalizedLanguageScript(DateFormatSymbols symbols,
-                                                    String[] months, int firstDayOfWeek,
+                                                    String[] months, String[] shortMonths, int firstDayOfWeek,
                                                     UIComponent uiComponent)
     {
         int realFirstDayOfWeek = firstDayOfWeek-1/*Java has different starting-point*/;
@@ -316,7 +317,7 @@
             throw new IllegalStateException("Week may only start with sunday or monday.");
 
         StringBuffer script = new StringBuffer();
-        defineStringArray(script, "jscalendarMonthName", months);
+        defineStringArray(script, "jscalendarMonthName", shortMonths);
         defineStringArray(script, "jscalendarMonthName2", months);
         defineStringArray(script, "jscalendarDayName", weekDays);
         setIntegerVariable(script, "jscalendarStartAt",realFirstDayOfWeek);

Reply via email to