Previous Page | Next Page

Hints and Tips for Creating Custom Portlets

Obtaining the User's Locale

In a portlet initializer or action class, you can obtain the user's locale from the user context. For information about obtaining the user context, see Obtaining a User and Session Context.

The following code obtains the SAS profile from the user context and then obtains the locale from the instance of the SASProfileInterface:

ProfileInterface profile = userContext.getProfile();
SASProfileInterface sasProfile =
  (com.sas.preferences.SASProfileInterface)profile.getProfile("SAS");
Locale locale = sasProfile.getLocale();

Note:   The locale is null if no value was available from the SAS profile. In this case, use the HttpServletRequest.getLocale() method instead.  [cautionend]

Previous Page | Next Page | Top of Page