问题描述
相当多,标题是什么。我需要使GWT DatePicker组件使用星期一作为一周的第一天。目前,日标是 S M T W T F S
,我希望它是 M T W T F S S
。任何方式完成它?如果自动区域设置检测不符合您的需求(并且可能会编辑 firstDayOfTheWeek
在 com.google.gwt.i18n.client.constants.DateTimeConstantsImpl_xy.properties
不会是),唯一的选项将修改DatePicker的实现:
-
扩展DatePicker,编写一个新的构造函数,调用受保护的
DatePicker(MonthSelector monthSelector,CalendarView视图,CalendarModel模型)
构造函数,具有您自己的视图和模型。 -
可以扩展CalendarModel ,所以你必须覆盖
getCurrentFirstDayOfFirstWeek
。 -
DefaultCalendarView
是最终的,所以你必须将它复制到一个新类,并修改其安装
方法。
这是相当凌乱,这是GWT的小缺点 - 这使得重你单身人士,而不是依赖注入...
Pretty much, what the title says. I need to make the GWT DatePicker component use Monday as the first day of the week. Currently the day labels are S M T W T F S
, I want it to be M T W T F S S
. Any way to accomplish it?
If the automatic locale detection doesn't fit your needs (and probably editing the firstDayOfTheWeek
in com.google.gwt.i18n.client.constants.DateTimeConstantsImpl_xy.properties
won't be either), the only option would be to modify the implementation of DatePicker:
Extend DatePicker, write a new constructor which calls the protected
DatePicker(MonthSelector monthSelector, CalendarView view, CalendarModel model)
constructor with your own view and model.The CalendarModel can be extended, so you'd have to override
getCurrentFirstDayOfFirstWeek
.The
DefaultCalendarView
is final, so you'd have to copy it to a new class and modify itssetup
method.
It's quite messy, and that's the little downside of GWT - it makes heavy use of Singletons instead of Dependency Injection...
这篇关于如何使GWT DatePicker使用星期一作为一周的第一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!