A Web browser is sometimes called a thin client because as a client, it does not have the rich set of features that a Notes client has. One notable deficiency is the ability for a Web browser to display numbers, dates, and times in a format that is appropriate for the user. For example, people in Germany expect to see dates in the order of day, month, and year separated by periods. Similarly a person in China expects dates to be in the order of year, month, and day. Date order confusion between the US format of mm/dd/yyyy and formats that use dd/mm/yyyy order is particularly common, and the effect of interpreting 6/11/2002 as November 6th can be disastrous! In the Notes client, numbers, dates, and times can be displayed using the regional preferences setting of the operating system, but until now, Web browsers could only display such items in whatever format the HTTP server uses.
In this article, we explore Web preferences, a new feature in Domino 6 that lets you set time zone and regional preferences for your Web browser. This article describes what is possible without any configuration on the client side, as well as enhancements that are possible with just a little effort from the user. Information is also provided for those who are interested in taking advantage of the new feature for their application development or server setup. This article is intended for Web browser users, system administrators, and application developers.
Date formatting and time zones: the Web browser vs. Notes client
Web servers send numbers and dates in HTML to browsers simply as text. The Web browser has no way of knowing which text is a date or which text is a number-all it can do is obediently display what the server sent to the user's screen. On the other hand, a Notes client knows that certain elements are dates or numbers and can display them appropriately to the user. The following figure illustrates how a date object stored on a server may be displayed in Notes clients and in Web browsers in different locations.
Figure 1. Date objects in Notes clients and Web browsers
The Notes client determines the desired format from the operating system, so even though the German user in Berlin accesses a server running in New York, the client is smart enough to display it using the German formatting rules and to ensure that the time is displayed in local time. (Of course, this assumes that the operating system of the computer in Berlin is set to German regional settings and that the date being displayed has not been forced into a particular format by the designer.) The Domino Web server in New York sends the date as plain text already formatted using its formatting rules, no matter where the browser is. The Web browsers can only display what is sent to them. As you can see, the Web browser in Berlin not only displays the date and time in an unacceptable format, but also the time is expressed in the time zone of the server!
Clearly, this would be a problem if you wanted to create a Web site to be used all around the world. But Domino 6 solves this problem very nicely at two levels. The first is completely automatic and takes advantage of the fact that modern Web browsers provide a small clue to the server about the user through the HTTP header called HTTP-accept-language. This header provides information indicating configurable locale preferences and is transmitted to a Web server each time the browser makes an HTTP request. For example, "en-US" indicates that the user prefers American English, "en-UK" indicates British English, and "de-DE" indicates standard German. Because there is a strong correlation between language and the rules for formatting dates and numbers, Domino 6 makes a determination as to which format is most appropriate for that user and then serves up the content appropriately.
So without anyone having to make any special configuration changes, numbers, dates, and times are served up in a format that is extremely likely to be what the user expects. As you can see in the following illustration, the Web browser in Berlin suggests German formatting rules and Domino 6 can then format dates using the d.m.yyyy format.
Figure 2. Date/time settings
Web browser language preferences
Most browsers let you define a list of languages that you accept with your most preferred language listed first. To see what your preferred language settings are:
- In Microsoft Internet Explorer,
choose Tools - Internet Options. On the General Tab, click the
Languages button to see the list:
Figure 3. Micorosft Internet Explorer Language Preference dialog box
- In Netscape Navigator, choose Edit
- Preferences, and then expand the Navigator category. Select the
Languages category to see the list:
Figure 4. Netscape Navigator Preferences dialog box
These language preferences do more than specify your preferred language. They also set certain locale preferences, such as date and time formats, associated with each language. The HTTP-accept-language header passes those preferences to the server.
But even with accept-languages defined in the browser, we are not out of the woods yet. The server cannot deduce which time zone the browser is in and as a result, cannot adjust the time component of a date/time to the local time of the user. Just because a person has German as their preferred language does not mean that they are in Germany, and a user with a setting of en_US could be in any one of a number of US time zones. As a result, the Berlin browser still shows the time as 10:23 (server local time) instead of 16:23.
Domino 6 solves this problem at the second level of the solution, which uses persistent browser cookies. Browser cookies allow additional information to be stored on the client computer and transmitted to the server whenever pages are requested from the same domain that created the cookie. For more information, on cookies see Netscape.com for "Cookies" or Microsoft.com for "Cookies: What They Are, Why You Are in Charge."
Simply put, Domino 6 allows Web users to define two cookies that customize their Web experience. One cookie allows the user to customize the formatting of dates, times, numbers, and currency settings; and the second cookie allows the customization of the time zone so that all dates and time can be correctly adjusted to your local time, including correct Daylight Saving Time compensation.
How do I set a cookie to tell the server what I want?
Domino 6 has an automatic, built-in URL that presents you with the pages that can be used to customize your settings. This URL is http://<server name>/$preferences.nsf?OpenPreferences. It looks like a URL for a standard Notes database, but in fact, the $preferences database is virtual and does not exist. The Domino 6 server recognizes this special URL.
You can embed this URL in any Web application, or you can simply provide it as a link to your users. The URL presents a frameset with two options on the left: Time Zone and Regional.
To set your time zone
When you select the Customize option to indicate that you do not want to use the server's time zone, the Time Zone page provides a list of time zones from which you can select your desired time zone. In addition, you can optionally override whether or not Daylight Saving Time (DST) is observed in that time zone. When you click Save, your Web browser creates a cookie and stores it locally on your computer. From then on, dates and times that Domino 6 serves up to that Web browser on that machine will be adjusted for that time zone. Not only can Domino 6 adjust to your time zone, but it also does so using the appropriate Daylight Saving Time rules for your time zone. This is important because many countries switch to DST on different dates.
Figure 5. Time Zone Preferences
Domino overrides the server's time zone settings with your preferences. However, if the application developer enforced a particular date/time format, Domino cannot override the server settings with your preferences.
By creating the Times Zone cookie, the results in the sample scenario improve. The users in Berlin now get the same date formatting and time zone experience in their Web browser as they do in their Notes client.
Figure 6. Date/time settings with time zone cookie
To set your regional settings
When you click the Regional option, the right-hand pane displays a comprehensive list of settings that you can use to customize dates, times, and numbers. Select the Customize option to indicate that you want to override the server settings that it associates with your preferred language. Selecting a locale from the list of locales and then clicking the "Load default preferences for this locale" button sets the default settings for that locale; you can decide if you want to use those default settings or customize them.
Figure 7. Regional Preferences
After you select the Customize option, you can work with the date and time settings and the various number formatting options:
Figure 8. Date, time, number, and currency settings
As with the Time Zone settings, when you click Save, your Web browser creates a cookie and stores it locally on your computer. From then on, all numbers, dates, and times that haven't been forced into a particular format by the designer are sent to the browser on that machine using your regional preferences. In addition, appropriate weekday and month names are used even if the date formatting has been set to a custom setting by the designer. These regional preferences override the locale preferences set when you specified a preferred language in your browser. When you leave either the server or the domain, the Web browser returns to the local preferences that you specified in the browser.
What scope do the cookies have and what information do they store?
In both the Time Zone and Regional Settings panes, a note appears at the bottom of the page indicating if your cookie is effective for the entire domain or just the particular server you are using. The scope of the cookie is determined by a server setting and is described in more detail later in this article. The two cookies expire ten years after being created or updated, so in other words, they are permanent. In addition to the information that is visible in the user interface, each cookie also stores a flag to indicate the validity of the cookie and a cookie version to allow for future enhancements. The Time Zone cookie stores the Daylight Saving Time rule for the selected time zone. The Regional Settings cookie also stores cookie character set information and a code indicating the default number of digits for the representation of years.
Try changing your Web preferences
You can try changing your Web preferences using the Lotus Domino 6 Web preferences demo. This demo lets you experiment with different Web preference settings and see the results in an embedded view on the demo page. Try it out!
Note that if your browser language preference is not set to en-us, you may already have noticed that some dates in areas on LDD are already formatted in your preferred format. When you work with the demo, you can choose a different langauge to see how the formatting changes.
Integrating Web preferences into Web applications
Web preferences were created in a very modular manner so that an application developer can select only the parts of the out-of-the-box feature that are needed. The simplest method is to create a link to the virtual URL: /$preferences.nsf?OpenPreferences either as a hotspot or as Pass-Thru HTML. This will bring users to a frameset that contains both the time zone and regional settings.
You can also create separate links to either or both time zone and regional settings by adding additional parameters to the URL, as follows:
Server control for Web preferences
What has to be done on the server to enable this feature? Nothing. By default the feature is enabled, but you can switch the feature off and make some adjustments. You can find the Web Preferences setting in the Server document or Web site document under the Internet Protocols - Domino Web Engine tabs. There you will find a new section called Web User Preferences:
Figure 9. Web User Preferences
There are two settings that you can adjust:
- Store user preferences in
cookies: This controls the generation
and acceptance of cookies. The options are:
Option Description Multi-server When users create cookies, they will be created for any server in the Internet domain. This is the default setting. Single server When users create cookies, they will be created for this server only. Disabled The feature will not generate HTML forms and code for creating the Web preferences cookies, and these cookies will be ignored.
Default regional locale: This controls the behavior in the absence of the
Regional Settings cookie from the browser. The options
Option Description Server locale Regional formatting will use the rules of the server. Browser's accept-language Regional formatting will adapt to the accept-language supplied by the browser. This is the default setting.
The following is a list of limitations that affect the Web preferences settings.
- Numbers, dates, and times that are
forced into a particular format by the application designer are not
affected by these preferences. If you want the user's Web
preferences to take effect, you must set the field or column
preference to "User setting." For example, for a date/time field in
a form, the "Use preferences from" option in the Field properties
box must be set to "User setting."
Figure 10. Field Properties box -- User setting
Similarly, view columns must also be set to use the user's preferences.
Figure 11. Column Properties box -- User setting
- Text conversions that are done using agents are not supported and will use the server settings as before.
- LotusScript code that depends on operating system locale or time zone is not influenced by the preferences cookies.
- Limitations of the cookie standards mean that for multi-server cookies, the server must be referred to by its own DNS name. IP addresses will not work.
- Cookies are stored locally on the browser's computer. This means that customizations made on one machine will not affect your browsing experience on another machine.
As this article has demonstrated, Domino 6 provides a richer browser experience with regard to appropriate formatting of numbers, dates, and times based on the already present browser accept-language. In addition, times can be adjusted to the user's time zone and default formatting options can be overridden with the aid of two independent browser cookies. Administrators can control the scope of the cookies to be server specific or domain-wide. Application developers can easily add links to access the cookie generation code. The Web user's experience is thus vastly improved with Domino 6.
- Web preferences demo
- Netscape: Cookies
- Microsoft: Cookies: What They Are, Why You Are In Charge
- Domino 6 Technical Overview
Dig deeper into IBM collaboration and social software on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Experiment with new directions in software development.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.