Hi,

you should set the same date format for the text field. For example, you can use DateTextField from the wicket-extensions project:

DateTextField dateField = new DateTextField("from", "d-M-yyyy");

Onno Scheffers wrote:
Hi,

how can I get the wicket.extensions.markup.html.datepicker.DateFormat (Wicket 1.2.6) to use a custom DateFormat? I keep getting validation problems as soon as I try to switch to another DateFormat.

HTML:
<input wicket:id="date" type="text" maxlength="10" /><span wicket:id="datePicker" />

Java:
     TextField dateField = new TextField("date", Date.class);
     dateField.setRequired(true);
     add(dateField);

     DatePicker dp = new DatePicker("datePicker", dateField);
     dp.setDateConverter(new DateConverter() {
        public DateFormat getDateFormat(Locale locale) {
           return new SimpleDateFormat("d-M-yyyy");
        }
     });
     add(dp);


When I leave out the call to setDateConverter, the default format seems to be MM/dd/yyyy for me. When setting the DateConverter like I did in the above code, the format seems to switch from MM/dd/yyyy to dd-MM-yyyy (instead of the expected d-M-yyyy?). So when I pick september 19th for example, it fills in 17-09-2007 into the TextField, but when I submit that value I get: '17-09-2007' is not a valid Date. Only '9/17/2007' or '09/17/2007' are accepted, which is weird since the DatePicker now puts a value into the textfield which is known to be invalid?

I also tried providing a DatePickerSettings object that overrides the getIfFormat(Locale) method to always return "%d-%m-%Y", but that didn't help either.

- Onno


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Andrew Klochkov


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to