public abstract class PortletRequestContextUtils extends Object
DispatcherServlet
.
Supports lookup of current WebApplicationContext, LocaleResolver, Locale, ThemeResolver, Theme, and MultipartResolver.
RequestContext
,
DispatcherServlet
Constructor and Description |
---|
PortletRequestContextUtils() |
Modifier and Type | Method and Description |
---|---|
static Locale |
getLocale(javax.portlet.PortletRequest request)
Retrieve the current locale from the given request, using the PortletLocaleResolver bound to the request by the
DispatcherServlet (if available), falling back to the request's accept-header Locale.
|
static PortletLocaleResolver |
getPortletLocaleResolver(javax.portlet.PortletRequest request)
Return the LocaleResolver that has been bound to the request by the DispatcherServlet.
|
static TimeZone |
getTimeZone(javax.portlet.PortletRequest request)
Retrieve the current time zone from the given request, using the TimeZoneAwareLocaleResolver bound to the request
by the DispatcherServlet (if available), falling back to the system's default time zone.
|
public static Locale getLocale(javax.portlet.PortletRequest request)
This method serves as a straightforward alternative to the standard Servlet PortletRequest.getLocale()
method, falling back to the latter if no more specific locale has been found.
Consider using LocaleContextHolder.getLocale()
which will normally be
populated with the same Locale.
request
- current HTTP requestgetPortletLocaleResolver(javax.portlet.PortletRequest)
,
LocaleContextHolder.getLocale()
@Nullable public static PortletLocaleResolver getPortletLocaleResolver(javax.portlet.PortletRequest request)
request
- current HTTP requestnull
if not found@Nullable public static TimeZone getTimeZone(javax.portlet.PortletRequest request)
Note: This method returns null
if no specific time zone can be resolved for the given request. This is
in contrast to getLocale(javax.portlet.PortletRequest)
where there is always the request's accept-header locale to fall back to.
Consider using LocaleContextHolder.getTimeZone()
which will normally
be populated with the same TimeZone: That method only differs in terms of its fallback to the system time zone if
the PortletLocaleResolver hasn't provided a specific time zone (instead of this method's null
).
request
- current HTTP requestnull
if none associatedgetPortletLocaleResolver(javax.portlet.PortletRequest)
,
LocaleContextHolder.getTimeZone()
Copyright © 2019 Liferay, Inc.. All rights reserved.