myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r635102 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
Date Sat, 08 Mar 2008 22:47:10 GMT
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);



Mime
View raw message