Author: frankbille
Date: Tue Feb 13 14:55:47 2007
New Revision: 507281

URL: http://svn.apache.org/viewvc?view=rev&rev=507281
Log:
Support for having a default selected date, which is then displayed in the 
calendar when opening it the first time.

Modified:
    
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/AbstractCalendar.java
    
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/DatePicker.java

Modified: 
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/AbstractCalendar.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/AbstractCalendar.java?view=diff&rev=507281&r1=507280&r2=507281
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/AbstractCalendar.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/AbstractCalendar.java
 Tue Feb 13 14:55:47 2007
@@ -16,6 +16,8 @@
  */
 package wicket.extensions.yui.calendar;
 
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
@@ -50,8 +52,21 @@
 // TODO provide localization strings (base them on the messages of
 // JsDatePicker?)
 public abstract class AbstractCalendar extends WebComponent {
-
        private static final long serialVersionUID = 1L;
+       
+       /**
+        * Format to be used when configuring YUI calendar. Can be used when 
using
+        * the "selected" property.
+        */
+       public static final DateFormat FORMAT_DATE = new SimpleDateFormat(
+                       "MM/dd/yyyy");
+       /**
+        * For specifying which page (month/year) to show in the calendar, use 
this
+        * format for the date. This is to be used together with the property
+        * "pagedate"
+        */
+       public static final DateFormat FORMAT_PAGEDATE = new SimpleDateFormat(
+                       "MM/yyyy");
 
        /**
         * Construct. Contributes packaged dependencies.

Modified: 
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/DatePicker.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/DatePicker.java?view=diff&rev=507281&r1=507280&r2=507281
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/DatePicker.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket-datetime/src/main/java/wicket/extensions/yui/calendar/DatePicker.java
 Tue Feb 13 14:55:47 2007
@@ -296,6 +296,12 @@
                widgetProperties.put("close", Boolean.TRUE);
                // TODO localize
                widgetProperties.put("title", "Select a date:");
+               
+               Date date = (Date) component.getModelObject();
+               if (date != null) {
+                       widgetProperties.put("selected", 
AbstractCalendar.FORMAT_DATE.format(date));
+                       widgetProperties.put("pagedate", 
AbstractCalendar.FORMAT_PAGEDATE.format(date));
+               }
        }
 
        /**


Reply via email to