如何使GWT DatePicker使用星期一作为一周的第一天? [英] How to make GWT DatePicker to use Monday as the first day of the week?

查看:135
本文介绍了如何使GWT DatePicker使用星期一作为一周的第一天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相当多,标题是什么。我需要使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 its setup 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使用星期一作为一周的第一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆