java.lang.Object
com.aoindustries.web.struts.LocaleFilter
- All Implemented Interfaces:
Filter
Resolves the current
Locale
, optionally changing it with any language parameters, and sets the request param
Constants.LOCALE
, and sets the thread locale.- Author:
- AO Industries, Inc.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
void
doFilter
(ServletRequest request, ServletResponse response, FilterChain chain) static Locale
getDefaultLocale
(SiteSettings siteSettings, ServletRequest request) Gets the default locale for the provided request.static Locale
getEffectiveLocale
(SiteSettings siteSettings, ServletRequest request, ServletResponse response) Gets the effective locale for the request.void
init
(FilterConfig fc)
-
Constructor Details
-
LocaleFilter
public LocaleFilter()
-
-
Method Details
-
init
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException - Specified by:
doFilter
in interfaceFilter
- Throws:
IOException
ServletException
-
destroy
public void destroy() -
getEffectiveLocale
public static Locale getEffectiveLocale(SiteSettings siteSettings, ServletRequest request, ServletResponse response) throws IOException, SQLException Gets the effective locale for the request. If the requested language is not one of the enabled languages for this site, will set to the default language (the first in the language list).Also allows the parameter
Constants.LANGUAGE
to override the current settings.This also sets the struts, JSTL, and response locales to the same value.
The thread locale is not set.
- Throws:
IOException
SQLException
-
getDefaultLocale
public static Locale getDefaultLocale(SiteSettings siteSettings, ServletRequest request) throws IOException, SQLException Gets the default locale for the provided request. The session and thread locale are not set.- Throws:
IOException
SQLException
-