cancel
Showing results for 
Search instead for 
Did you mean: 

Datanavigator property firstDayOfWeek

maarten_duits2
Participant
0 Kudos

Hello,

Where are using ESS/MSS leave request. One of the options is that you can display a calendar. The first day of the week is a Sunday, which is not correct for country Netherlands. Our first day of the week is Monday. I checked the standard SAP Java webdynpro and saw that the property firstDayOfWeek of the datenavigator is set to Auto. When the property is set to Auto the WebDynpro will specify the first day of the week automatically, according to the country-specific beginning of the week.

What i would like to know is, can somebody tell me where the Webdynpro finds the country so it can display the correct first day of the week. Does the WebDynpro looks on the server where it is deployed, or on the client or is it a setting in the Visual Administrator?

Thanks in advance.

Kind regards,

Maarten

Accepted Solutions (1)

Accepted Solutions (1)

maarten_duits2
Participant
0 Kudos

Hello,

Thanks for all the answers.

I created a WebDynpro view with just a DateNavigator on it. I didn't changed the properties (everything default). In the onInit i placed the following code:

 
Locale locale = WDClientUser.getLoggedInClientUser().getLocale(); 
wdComponentAPI.getMessageManager().reportWarning("Locale (WDClientUser.getLoggedInClientUser) --> " + locale); 

IWDResourceHandler resourceHandler = WDResourceHandler.createResourceHandlerForCurrentUser(); 
wdComponentAPI.getMessageManager().reportWarning("Locale (WDResourceHandler.createResourceHandler) --> " + resourceHandler.getLocale()); 

Locale local = WDResourceHandler.getCurrentSessionLocale(); 
wdComponentAPI.getMessageManager().reportWarning("Locale (WDResourceHandler.getCurrentSessionLocale) --> " + local); 

The result is:

Locale (WDClientUser.getLoggedInClientUser) --> nl

+Locale (WDResourceHandler.createResourceHandler) --> nl+

Locale (WDResourceHandler.getCurrentSessionLocale) --> nl

The first day of the week in the datenavigator is still Sunday instead of Monday.

I think that i should start an OSS Call. Anyone another suggestion?

Kind regards,

Maarten.

Edited by: Maarten Duits on Jan 18, 2010 12:26 PM -typos

Former Member
0 Kudos

Have you checked this one:

Locale locale = WDClientUser.getLoggedInClientUser().getLocale();

Calendar loCalendar = Calendar.getInstance(locale);

loCalendar.getFirstDayOfWeek();

Because the problem could be in the initialization of datenavigator ui and if it is there then you can easily fix the problem.

Regards,

Anton

maarten_duits2
Participant
0 Kudos

Hello Anton,

The result of your piece of code is: 2 (Monday). This is the correct result. But the DateNavigator still gives Sunday as first day. Could you tell me how fix the initialization problem of the dateNavigator?

Thx in advance.

Kind regards,

Maarten.

Former Member
0 Kudos

You can do this in one of the following ways:

1). Go in the view where your DateNavigator is placed and write the following code in the wddomodify method

if (firstTime) {

....

Locale locale = WDClientUser.getLoggedInClientUser().getLocale();

Calendar loCalendar = Calendar.getInstance(locale);

IWDDateNavigator loNavigator = (IWDDateNavigator)view.getElement("<YOUR DATE NAVIFATOR UI ELEMENT ID>");

loNavigator.setFirstDayOfWeek(WDDayOfWeek.valueOf(loCalendar.getFirstDayOfWeek()));

}

2). In the same view you can create a context element of type dayofweek and bind it to firstdayofweek property of DateNavigator, then in wddoinit method:

Locale locale = WDClientUser.getLoggedInClientUser().getLocale();

Calendar loCalendar = Calendar.getInstance(locale);

wdContext.currentContextElement().setFirstDayOfWeek(WDDayOfWeek.valueOf(loCalendar.getFirstDayOfWeek()));

In either of two ways you are avoiding using the 'auto' value of firstdayofweek property, and now everything should work properly.

Best regards,

Anton

maarten_duits2
Participant
0 Kudos

Anton,

Thank you.

Unfortunately it's SAP standard, so i think i open a OSS message.

Kind regards,

Maarten

Answers (3)

Answers (3)

Former Member
0 Kudos

I think it is an internal problem, but I don't know where it is. We have the same problem, but in my case the problem occurred in 7.0 sp 12, after the upgrade to sp16 problem disappeared. You could test of course: create calendar with the current locale and get its first date of week, if it returns the correct one than the problem is in initialization code of the datenavigator ui element (and you can write two lines of code to initialize it with the correct value), if it also returns wrong value than it must be some problem in localization definitions or something other related to localizations (or may be in the calendar class ). But as you said, OSS message is also an option :).

Best regards,

Anton

Former Member
0 Kudos

The DateNavigator UI element with firstDayOfWeek=AUTO uses a Calendar that is initialized with the session locale. The first day of week is then defined by that Calendar object (at least this is what I see in the 7.11 code).

Armin

maarten_duits2
Participant
0 Kudos

Hi all,

Thx for the quick replies.

I just check, with the code of Omri what my locale is. It's nl, which is correct. As mentioned in the first post, the Calendar in leaverequest shows as first day of the week Sunday. Which is not correct for nl.

Anyone another idea? Or should i make an OSS request?

Kind regards,

Maarten.

Former Member
0 Kudos

Could you check with the debugger what the following method returns:

http://help.sap.com/javadocs/nwce/ce71/wdr/com/sap/tc/webdynpro/services/sal/localization/api/WDReso...

Armin

former_member182374
Active Contributor
0 Kudos

Hi,

You can use the following code to check the Locale of the user

Locale locale = WDClientUser.getLoggedInClientUser().getLocale();
wdComponentAPI.getMessageManager().reportWarning("Locale --> " + locale);

Regards,

Omri