0

I need to set my own date pattern and locale on jQuery UI DatePicker in Wicket. The problem is that DatePicker seems to be ignoring all settings. Here is my code:

dateField = new DatePicker("dateField", new ComponentPropertyModel<>(id), "d.M.yyyy", new Options());

System.out.println("locale: " + dateField.getLocale());
System.out.println("format: " + dateField.getTextFormat());

add(dateField);

Output in stdout looks promising:

locale: cs
format: d.M.yyyy

But still on page I see only english locale and absolutely different date format.

enter image description here

Am I doing something wrong or there is just bug in jQuery UI for Wicket? And how can I fix it?

Thanks in advance!

Firzen
  • 1,909
  • 9
  • 28
  • 42

1 Answers1

1

Today I have finally solved this issue by following How do I localize the jQuery UI Datepicker?.

You just need to download jQuery UI from https://github.com/jquery/jquery-ui, and then copy files from ui/i18n into your project.

And then you will need to use right JS file in your HTML markup, so you can solve it like this:

public void renderHead(IHeaderResponse response) {
    try {
        String locale = datePicker.getLocale().toString();
        String path = "scripts/datepicker/datepicker-" + locale + ".js";

        response.render(JavaScriptHeaderItem.forUrl(path));
    }
    catch (Exception e) {
        // ignored at this moment
    }
}
Community
  • 1
  • 1
Firzen
  • 1,909
  • 9
  • 28
  • 42