Author: ivaynberg
Date: Tue Feb  3 16:32:24 2009
New Revision: 740343

URL: http://svn.apache.org/viewvc?rev=740343&view=rev
Log:
WICKET-2072

Modified:
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java?rev=740343&r1=740342&r2=740343&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
 Tue Feb  3 16:32:24 2009
@@ -267,6 +267,12 @@
                                }
                                calendarInit.append("]");
                        }
+                       else if (value instanceof Map)
+                       {
+                               calendarInit.append(":");
+                               Map map = (Map)value;
+                               appendMapping(map, calendarInit);
+                       }
                        else
                        {
                                calendarInit.append(":");
@@ -629,7 +635,8 @@
         * selection of month and year.
         * 
         * @return <code>true</code> if select boxes should be rendered to 
allow month and year
-        *         selection.<br/> <code>false</code> to render just plain text.
+        *         selection.<br/>
+        *         <code>false</code> to render just plain text.
         */
        protected boolean enableMonthYearSelection()
        {
@@ -639,9 +646,8 @@
        /**
         * Indicates whether the calendar should be hidden after a date was 
selected.
         * 
-        * @return <code>true</code> (default) if the calendar should be hidden 
after the date
-        *         selection <br/> <code>false</code> if the calendar should 
remain visible after the
-        *         date selection.
+        * @return <code>true</code> (default) if the calendar should be hidden 
after the date selection <br/>
+        *         <code>false</code> if the calendar should remain visible 
after the date selection.
         */
        protected boolean hideOnSelect()
        {
@@ -659,12 +665,50 @@
                return false;
        }
 
+
+       private void appendMapping(Map map, StringBuffer calendarInit)
+       {
+               boolean first = true;
+               calendarInit.append("{");
+               Iterator keys = map.keySet().iterator();
+               while (keys.hasNext())
+               {
+                       final Object key = keys.next();
+                       if (first)
+                       {
+                               first = false;
+                       }
+                       else
+                       {
+                               calendarInit.append(",");
+                       }
+                       
calendarInit.append(Strings.toEscapedUnicode(key.toString()));
+                       calendarInit.append(":");
+                       if (map.get(key) instanceof Map)
+                       {
+
+                               Map value = (Map)map.get(key);
+                               appendMapping(value, calendarInit);
+                       }
+                       else
+                       {
+                               // calendarInit.append(map.get(key).toString());
+                               calendarInit.append("\"");
+                               
calendarInit.append(Strings.toEscapedUnicode(map.get(key).toString()));
+                               calendarInit.append("\"");
+                       }
+               }
+               calendarInit.append("}");
+       }
+
        /**
         * Override this method to further customize the YUI Calendar with 
additional Javascript code.
         * The code returned by this method is executed right after the 
Calendar has been constructed
-        * and initialized. To refer to the actual Calendar DOM object, use 
<code>${calendar}</code>
-        * in your code.<br/> See <a 
href="http://developer.yahoo.com/yui/calendar/";>the widget's
-        * documentation</a> for more information about the YUI Calendar.<br/> 
Example:
+        * and initialized. To refer to the actual Calendar DOM object, use 
<code>${calendar}</code> in
+        * your code.<br/>
+        * See <a href="http://developer.yahoo.com/yui/calendar/";>the widget's 
documentation</a> for
+        * more information about the YUI Calendar.<br/>
+        * Example:
         * 
         * <pre>
         * protected String getAdditionalJavascript()


Reply via email to