Datefield week numbers

There’s a method for enabling week numbers in Datefield.setShowISOWeekNumbers(boolean). However, I cannot see any week numbers in the selector widget. Is this a bug or am I doing something wrong? I’m using Vaadin 7.4.4 and here’s the code in question:

final DateField startDate = new DateField("Start Date") ;
startDate.setValue(new java.util.Date()) ;
startDate.setShowISOWeekNumbers(true) ;

Thanks much


Week numbers
seem to work just fine
for me with Vaadin 7.4.2 and 7.4.5. You seem to be doing it right there, so I can’t tell what could cause your problems.

the Sampler example for DateField
, the setting does not seem to have effect, but that could also be a problem in the application. There’s even
about that.

Perhaps this is a misunderstanding on my part on how this actually functions. I was under the impression that displaying week numbers would actually show a number somewhere for the week number (“1”, “2”, “3”, etc) - but I do not see them in the “seem to work just fine” link you posted. Can you please post a screenshot of what this is supposed to look like with week numbers enabled? (On a DateField - not a Calendar)
Thanks much

Ah, there’s the “small print” in setShowISOWeekNumbers():

Unfortunately, in some locales such as en_US, the week starts on Sunday. In such case, the week numbers are therefore not shown.

The example I mentioned got the locale from the browser, for me fi_FI, and probably in your locale weeks start on Sunday.

During my investigation I’ve found that the locale drives which type of Calendar object gets created. Do you happen to know enough about the Vaadin code to point me at what class/method is making the determination to display week numbers? Even though my week starts on Sunday, I’d still like the week numbers to appear. I have been able to successfully inject a custom Calendar object into a custom DateField - I just need to know what’s being checked that determines whether week numbers are displayed so I can override it.
Thanks again

Unfortunately, the decision logic is done on the client-side in AbstractDateFieldConnector.

        // We show week numbers only if the week starts with Monday, as ISO 8601
        // specifies
                        && getWidget().dts.getFirstDayOfWeek() == 1);

Hence it gets complicated. You’d either need to override the updateFromUIDL() method in a sub-class OR make a DateField extension that modifies the setting somehow. Extensions are usually lighter to implement and avoid some troubles with class hierarchy. For example, if you want to subclass the connectors, you’d need to subclass both InlineDateFieldConnector and PopupDateFieldConnector, as well as the server-side classes… Extensions on the other hand are more limited in how they can hook into things; they can’t easily override behaviour. I’m not even sure if you can override the setting in an extension.

Also, if you use the ISO week numbering scheme in US English calendar, the week numbering could go very wrong on some dates. For example, if New Year’s Day is on Monday, etc.

Well in actuality what I ultimately desire is to 1) have the week numbers appear on the datefield so that I can 2) override the week number value based on my own logic (where the number essentially increases by one every two weeks). Given that, is there a way to more easily override how this date field is painted? (E.g. somehow add an extra column to put whatever value I want in it?)
Thanks again