来自 Wicket jQuery UI 的 DatePicker 忽略模式和语言环境
DatePicker from Wicket jQuery UI ignores pattern and locale
我需要在 Wicket 的 jQuery UI DatePicker 上设置我自己的日期模式和区域设置。问题是 DatePicker 似乎忽略了所有设置。这是我的代码:
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);
stdout 中的输出看起来很有希望:
locale: cs
format: d.M.yyyy
但在页面上我仍然只看到英语语言环境和完全不同的日期格式。
我是做错了什么,还是 Wicket 的 jQuery UI 中存在错误?我该如何解决?
提前致谢!
今天终于解决了这个问题,关注了How do I localize the jQuery UI Datepicker?。
您只需从 https://github.com/jquery/jquery-ui 下载 jQuery UI,然后将 ui/i18n
的文件复制到您的项目中。
然后你需要在你的 HTML 标记中使用正确的 JS 文件,所以你可以这样解决它:
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
}
}
我需要在 Wicket 的 jQuery UI DatePicker 上设置我自己的日期模式和区域设置。问题是 DatePicker 似乎忽略了所有设置。这是我的代码:
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);
stdout 中的输出看起来很有希望:
locale: cs
format: d.M.yyyy
但在页面上我仍然只看到英语语言环境和完全不同的日期格式。
我是做错了什么,还是 Wicket 的 jQuery UI 中存在错误?我该如何解决?
提前致谢!
今天终于解决了这个问题,关注了How do I localize the jQuery UI Datepicker?。
您只需从 https://github.com/jquery/jquery-ui 下载 jQuery UI,然后将 ui/i18n
的文件复制到您的项目中。
然后你需要在你的 HTML 标记中使用正确的 JS 文件,所以你可以这样解决它:
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
}
}