You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/03/08 23:47:10 UTC

svn commit: r635102 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java

Author: lu4242
Date: Sat Mar  8 14:46:56 2008
New Revision: 635102

URL: http://svn.apache.org/viewvc?rev=635102&view=rev
Log:
fix TOMAHAWK-1209 HtmlCalendar.getLocalizedLanguageScript called form HtmlDateRenderer throws ClassCastException

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java?rev=635102&r1=635101&r2=635102&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java Sat Mar  8 14:46:56 2008
@@ -410,7 +410,6 @@
                                                     int firstDayOfWeek, UIComponent uiComponent,
                                                     String popupCalendarVariable)
     {
-        HtmlInputCalendar calendar = (HtmlInputCalendar) uiComponent;
 
         // Convert day value to java.util.Date convention (Sun=0, Mon=1, Sat=6). This is
         // the convention that javascript Date objects use.
@@ -437,29 +436,43 @@
         StringBuffer script = new StringBuffer();
         AddResource ar = AddResourceFactory.getInstance(facesContext);
 
-        // Set the themePrefix variable
-        String popupTheme = calendar.getPopupTheme();
-        if (popupTheme == null)
+        if (uiComponent instanceof HtmlInputCalendar)
         {
-            popupTheme = "DB";
-        }
-        setStringVariable(script,popupCalendarVariable + ".initData.themePrefix", "jscalendar-" + popupTheme);
-
-        // specify the URL for the directory in which all the .gif images can be found
-        String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
-        if(imageLocation == null)
-        {
-            String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, popupTheme + "/");
-            setStringVariable(script,popupCalendarVariable + ".initData.imgDir",
+            HtmlInputCalendar calendar = (HtmlInputCalendar) uiComponent;
+            // Set the themePrefix variable
+            String popupTheme = calendar.getPopupTheme();
+            if (popupTheme == null)
+            {
+                popupTheme = "DB";
+            }
+            setStringVariable(script,popupCalendarVariable + ".initData.themePrefix", "jscalendar-" + popupTheme);
+
+        
+            // specify the URL for the directory in which all the .gif images can be found
+            String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
+            if(imageLocation == null)
+            {
+                String uri = ar.getResourceUri(facesContext, HtmlCalendarRenderer.class, popupTheme + "/");
+                setStringVariable(script,popupCalendarVariable + ".initData.imgDir",
                               JavascriptUtils.encodeString(uri));
+            }
+            else
+            {
+                setStringVariable(script, popupCalendarVariable +".initData.imgDir",
+                              (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext)
+                                                            .getResourceUri(facesContext, imageLocation+"/"))) );
+            }
         }
         else
         {
-            setStringVariable(script, popupCalendarVariable +".initData.imgDir",
-                              (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext)
-                                                            .getResourceUri(facesContext, imageLocation+"/"))) );
+            String imageLocation = HtmlRendererUtils.getImageLocation(uiComponent);
+            if (imageLocation != null)
+            {
+                setStringVariable(script, popupCalendarVariable +".initData.imgDir",
+                        (JavascriptUtils.encodeString(AddResourceFactory.getInstance(facesContext)
+                                                      .getResourceUri(facesContext, imageLocation+"/"))) );                
+            }
         }
-
         defineStringArray(script, popupCalendarVariable +".initData.monthName", mapMonths(symbols));
         defineStringArray(script, popupCalendarVariable +".initData.dayName", weekDays);
         setIntegerVariable(script, popupCalendarVariable +".initData.startAt",realFirstDayOfWeek);